(v1) Unify error normalization and formatting - #1157
Conversation
|
Run failed. View the logs →
|
🦋 Changeset detectedLatest commit: df221c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Run failed. View the logs →
|
arkenv
@arkenv/build
@arkenv/bun-plugin
@arkenv/cli
@arkenv/fumadocs-ui
@arkenv/nextjs
@arkenv/nuxt
@arkenv/vite-plugin
commit: |
📦 Bundle Size Report
✅ All size limits passed! |
There was a problem hiding this comment.
Reviewed changes — First review of this PR. Introduces EnvIssue type normalization across both ArkType and Standard Schema engines, safeCreateEnv non-throwing API, and sensitive-value redaction in error messages.
- Introduce
EnvIssuetype withcode,expected,received,metafields replacing the flatValidationIssuetype incore.ts; deprecate old type as alias. - Add
safeCreateEnvto botharkenvandarkenv/standardreturning aSafeCreateEnvResult<T>discriminated union instead of throwing. - Implement secret redaction via
SENSITIVE_KEYWORDSregex patterns,shouldRedact(),safeStringify(), anddebugSecretsconfig/ARKENV_DEBUG_SECRETSenv var. - Normalize Standard Schema errors in
parse-standard.tsto resolve received values (JSON-parse + traversal), map engine-level codes toEnvIssueCode, and append styled(was …)values. - Map ArkType error codes to
EnvIssueCodeinarkErrorsToIssueswith properexpected/receivedextraction and redaction support. - Update
ArkEnvErrorto storeissuespublicly and acceptdebugSecretsoptions. - Add
formatIssues/formatErrorutilities with deprecatedformatInternalErrorsalias. - Add changeset marking a minor version bump with breaking-change notice for error message format.
- Add/update tests in
errors.test.tsandstandard-mode.test.tsfor redaction,safeCreateEnv, and error normalization.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Reviewed changes — incremental delta since the prior Pullfrog review. The 94f275f commit addresses both review threads: tightened sensitive-keyword regex patterns, added a public exclusion in shouldRedact, and removed the unused _options/options parameters across formatting functions and the ArkEnvError constructor.
- Tightened
SENSITIVE_KEYWORDSregex patterns — broad patterns like/key/i,/pass/i,/auth/iare now anchored to(_|^)...(_|$)boundaries to avoid false positives on non-sensitive variable names (COMPASS, AUTHOR, etc.). - Added
publicexclusion inshouldRedact— paths containingpublic(e.g.PUBLIC_KEY) are no longer redacted, even when they match a sensitive keyword pattern. - Removed unused
_optionsparameter fromformatIssues,formatError, and the deprecatedformatInternalErrors— the parameter was never wired through since redaction happens at issue-creation time. - Removed unused
optionsparameter from theArkEnvErrorconstructor, along with a duplicateformatIssuescall in the constructor body. - Cleaned up
parse-standard.tserror construction — theconfigpassthrough toArkEnvError(which was ignored) has been removed.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…timizing standard error mapping
There was a problem hiding this comment.
Reviewed changes — incremental delta since the prior Pullfrog review. The 083837c commit extracts redaction utilities into a shared module and optimizes the Standard Schema error mapping to resolve size-limit failures.
- Extracted
safeStringify/shouldRedact/SENSITIVE_PATTERNtosrc/utils/redact.ts— moved out ofcore.tsandarktype/index.tsinto a shared utility module; consolidated 11 separate regex patterns into a single combined pattern. - Optimized
parse-standard.tserror mapping — extractedgetProphelper for path traversal, deduplicated type-checks viamsgvariable, consolidated meta extraction with??nullish coalescing, and streamlined message-suffix construction. - Bumped size-limit thresholds in
package.jsonto2.3 kB(arkenv) and2.1 kB(arkenv/standard).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
# Conflicts: # packages/arkenv/package.json # packages/arkenv/src/arkenv.ts # packages/arkenv/src/arktype/index.ts # packages/arkenv/src/index.ts # packages/arkenv/src/parse-standard.ts # packages/arkenv/src/standard-mode.test.ts # packages/arkenv/src/standard.ts
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes — incremental delta since the prior Pullfrog review at 083837c. Renames create-env.ts → arkenv.ts and createEnv() → arkenv(), reorganizes imports from @/ aliases to relative paths, adds coerce/arrayFormat/emptyAsUndefined/debugSecrets config options to ParseStandardConfig, adds safeCreateEnv to the arkenv/standard entry point, exposes getSchemaKeys from the main index, and bumps size-limit thresholds.
- Renamed
create-env.tstoarkenv.ts— file moved, functioncreateEnvrenamed toarkenv,safeCreateEnvmoved alongside. Updated all internal callers, re-exports, and type references. - Reorganized
arktype/index.tsimports — replaced@/arkenv,@/coercion,@/core,@/utils/style-textalias imports with relative.tspaths. Removed.tsextensions from two imports incore.ts. - Added coercion and redaction config to
ParseStandardConfig— newcoerce,arrayFormat,emptyAsUndefined, anddebugSecretsoptions flow through the Standard Schema path alongside the existing ArkType path. - Wired
emptyAsUndefinedcoercion pipeline inparse-standard.ts—stripEmptyStringsapplied toenvbefore validation; extractedprocessedEnvvariable used consistently in received-value traversal. - Added
safeCreateEnvtoarkenv/standardentry — mirrors the non-throwing API from the mainarkenvexport. - Exposed
getSchemaKeysfrom the main index — new public utility for extracting keys from schema definitions in either ArkType or Standard Schema format.
ℹ️ Dead formatIssuePath function
formatIssuePath at packages/arkenv/src/parse-standard.ts:150 is defined but never called. The inline getProp helper + path construction replaced the call site at line 252, but the function wasn't removed. Since both implementations produce the same result, one is dead code.
Technical details
# Dead `formatIssuePath` function
## Affected sites
- `packages/arkenv/src/parse-standard.ts:150` — `formatIssuePath` function definition, no callers via grep
## Required outcome
- Remove the unused `formatIssuePath` function or replace the inline `getProp` + `${key}.${issue.path.map(getProp).join(".")}` pattern with a call to it.ℹ️ Nitpicks
packages/arkenv/src/arkenv.ts:39— JSDoc still referencescreateEnv(stale from the rename toarkenv).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — delta since the prior Pullfrog review at 979c137. Replaces the standalone safeArkEnv function with a { safe: true } option on arkenv(), and changes SafeArkEnvResult from exposing the full error object to returning issues directly.
- Replaced
safeArkEnvwith{ safe: true }option — added overload signatures distinguishing the safe (SafeArkEnvResult<T>) and throwing (T) return types in botharkenv.ts(6 overloads) andstandard.ts(2 overloads). All call sites, tests, and documentation updated toarkenv(def, { safe: true }). - Changed
SafeArkEnvResultfailure branch from{ success: false; error: ArkEnvError }to{ success: false; issues: readonly EnvIssue[] }.executeSafenow extractserror.issuesdirectly.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…ing validation results
… formatError to enforce bundle isolation
…igurations and allow optional meta in error reporting
…dation error types
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — 10 new commits since the prior Pullfrog review at f922185. Strips engine-specific metadata from EnvIssueMeta, removes the deprecated formatError() wrapper, expands error code maps with type-safe exhaustiveness, and hardens framework integrations against the safe: true option.
- Removed engine metadata from
EnvIssueMeta— fieldsengineandengineCodestripped from the type, all call sites, and all test assertions. Justified by the new ADR 0010 on bundle isolation. - Removed
formatError()— the deprecated wrapper overformatIssues()is gone; all callers and tests updated. Changeset note updated accordingly. - Expanded
ARKTYPE_CODE_MAP— new codesminLength,unit,proto,domain,exactLength,before,after,predicatemapped; type-safe viasatisfies Record<ArkError["code"], EnvIssueCode>withinoperator guard inmapArkTypeCode. STANDARD_CODE_MAPnow usessatisfies Record<string, EnvIssueCode>andinoperator lookup, matching the ArkType pattern.- Made
buildEnvIssue'smetaparameter optional — defaults to{}, consistent with the now-optionalmetafield onEnvIssue. - Hardened framework integrations — all plugin configs (
vite,bun,nextjs,nuxt) now type-restrictsafeviaOmit<ArkEnvConfig, "safe">and explicitly passsafe: falseat runtime. - Added ADR 0010 — bundle isolation over DRYness, documenting why the two parsing engines remain split despite visual similarity.
- Added
safeoption docs —options.mdxdocuments thesafeoption with an integration caveat;quickstart.mdxupdated with pattern. - Updated changeset and skills — changeset text tightened (
safeArkEnvAPI →{ safe: true }API),formatErrorreference removed;changeset/SKILL.mdadded v1+ bump rules table. - Vite test mocks — added
as anyonmockReturnValuecalls to satisfy the richer return-type union.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…ze warning/error prefixes (#1294) ## Summary Introduces a dedicated `log.ts` utility module in `@arkenv/build` and migrates all manually-prefixed log strings in the build-time and framework integration packages to use it. ## Changes ### `@arkenv/build` - **New:** `packages/build/src/log.ts` — defines `BUILD_PREFIX`, `WATCHER_PREFIX`, `formatBuildError`, `logBuildWarning`, `logBuildError`, `logWatcherError` - Re-exports `./log` from `index.ts` - Replaces raw string literal in `resolveLayout` and all `console.error` calls in `watchSchema`/`closeWatcher` ### `@arkenv/nextjs` - `config.ts`: uses `logBuildWarning`, `logBuildError`, `formatBuildError` for deprecation warning, schema path error, codegen error, and validation failure header - `arkenv-internal.ts`: uses `logBuildWarning` for legacy nested-layout deprecation ### `@arkenv/nuxt` - `module.ts`: uses `formatBuildError` for the client-side server-only import error ## Motivation Follows up on #1157 — while that PR fixed casing inconsistencies, the prefix strings were still scattered as manual literals across 5+ call sites. This extracts them into a single, zero-dependency helper module inside `@arkenv/build` (already a shared dep) so all integrations stay consistent automatically. ## Verification - 73 test files, **743 tests** — all passing ✅ --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>

Fixes #709
Refactor the error system to use a normalized EnvIssue format, support sensitive credential masking/redaction with programmatic overrides, add a non-throwing safeCreateEnv API for RSC/Next.js integrations, and provide a stable base for CLI/IDE integrations.