-
Notifications
You must be signed in to change notification settings - Fork 6
(v1) Unify error normalization and formatting #1157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
427ced6
fix: tackle issue #709
yamcodes ca7c067
fix: resolve biome formatting and sync examples issues
yamcodes df34eed
Merge branch 'dev' into 709-unify-error-normalization-and-formatting
yamcodes 94f275f
fix: address PR review comments on error formatters and sensitive key…
yamcodes 083837c
fix: resolve size-limit failures by splitting redact utilities and op…
yamcodes b2b2e85
fix: resolve exactOptionalPropertyTypes errors in parse-standard.ts
yamcodes c0a5415
Merge branch 'v1' into 709-unify-error-normalization-and-formatting
yamcodes 99c91e5
Merge branch 'v1' into 709-unify-error-normalization-and-formatting
yamcodes 2321b1c
refactor: reorder internal imports and exports for improved consistency
yamcodes 6a8da0c
fix: validate rawVal type in parse-standard and update bundle size li…
yamcodes dd03fe5
refactor: extract getProp helper and add code-review skill definition
yamcodes 160e78f
refactor: centralize error mapping and metadata extraction for ArkTyp…
yamcodes f187548
fix(review): remove test file .ts extensions, restructure changeset, …
yamcodes 2aa8a93
docs(skill): clarify that gh pr view completely omits inline code rev…
yamcodes 52ff00c
refactor: remove redundant index file references from import paths ac…
yamcodes e51c73b
docs(changeset): elaborate on breaking change error message details
yamcodes 0658e96
refactor: migrate root entrypoint imports from @/ to @ and update tsc…
yamcodes 9b4eb34
refactor: use @ instead of @/index in dynamic import in isolation test
yamcodes fe83263
refactor: resolve second round of PR comments on error formatting and…
yamcodes 40432cf
[autofix.ci] apply automated fixes
autofix-ci[bot] df87424
refactor: use imperative verb form and remove implementation details …
yamcodes e6ffea9
refactor: consolidate environment coercion logic and standardize path…
yamcodes 4539b0a
refactor: replace Record<string, unknown> with Dict<string> in enviro…
yamcodes c90f532
refactor: move coerceEnvironment to dedicated module and update error…
yamcodes ad54a52
feat: upgrade arkenv to major version and document breaking API chang…
yamcodes 53ba7dc
feat: import Dict type from repo types for shared coercion utilities
yamcodes c3fc46a
chore: add job execution logs and update package dependencies
yamcodes 979c137
docs(review): resolve PR #1157 review comments, document safeArkEnv
yamcodes 5d4e876
docs: document architectural design decisions regarding module isolat…
yamcodes aefb0d7
feat: add documentation for hiding internal comments from .d.ts files…
yamcodes 63fa480
docs: address review comments
yamcodes 101fbc9
refactor: update safeArkEnv return type to provide issues directly in…
yamcodes da4c544
refactor: replace safeArkEnv utility with a safe option in the arkenv…
yamcodes f922185
[autofix.ci] apply automated fixes
autofix-ci[bot] 16e4d27
feat: add { safe: true } configuration option to arkenv for non-throw…
yamcodes 6737534
refactor: remove engine-specific metadata from EnvIssue and deprecate…
yamcodes 5066f2a
style: fix minor whitespace inconsistencies and clean up code formatting
yamcodes de18bbc
feat: disable strict validation by setting safe: false in plugin conf…
yamcodes 43c7858
refactor: omit safe property from ArkEnvConfig in vite and bun plugin…
yamcodes 3dd42d7
docs: clarify that the safe option is unsupported in bun and vite plu…
yamcodes ceb0496
docs: document the safe option and its limitations in framework integ…
yamcodes 10a2103
refactor: enforce strict type safety for error code mappings using sa…
yamcodes befc6c9
fix: ensure type safety when accessing error maps by using the 'in' o…
yamcodes 43206f2
fix: update error code mappings to support comprehensive ArkType vali…
yamcodes 0ca680b
docs: remove safe parsing documentation from quickstart guide
yamcodes c9532d0
refactor: rename executeSafe to safeExecute for consistent naming con…
yamcodes 11999c9
feat: remove safe option from integrations and enforce safe: false in…
yamcodes df221c2
chore: ignore job_logs.txt and clear existing log entries
yamcodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
|
yamcodes marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| "arkenv": major | ||
| --- | ||
|
|
||
| #### Refactor error system to use normalized `EnvIssue` and add `{ safe: true }` API | ||
|
|
||
| Introduce a unified `EnvIssue` type for programmatic access to validation issues via `ArkEnvError.issues`, and add the non-throwing `{ safe: true }` configuration option to `arkenv`. | ||
|
|
||
| Error messages now use ANSI colors instead of a bullet-point prefix: | ||
|
|
||
| ```diff | ||
| - - [PORT] must be a valid port number (was "invalid-port") | ||
| + PORT must be a valid port number (was "invalid-port") | ||
| ``` | ||
|
|
||
| Note: Header (red), variable path (yellow), and received value (cyan) are now styled with ANSI escape codes. Update any test suites asserting on exact error text. | ||
|
|
||
| **BREAKING CHANGE**: `ValidationIssue` and `formatInternalErrors` removed. Use `EnvIssue` and `formatIssues` instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # 10. Bundle Isolation trumps DRYness | ||
|
|
||
| Date: 2026-06-21 | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted | ||
|
|
||
| ## Context | ||
|
|
||
| ArkEnv operates as a zero-dependency environment variable parser. It uses ArkType as its primary validation engine (`arkenv`), while also offering a completely separate entry point (`arkenv/standard`) that leverages Standard Schema 1.0 (for users preferring Zod, Valibot, etc.). | ||
|
|
||
| During the refactoring to a single core repository with multiple internal exports, a code review raised concerns about code duplication between `src/arktype/index.ts` and `src/parse-standard.ts`. Both files implement similar logic for parsing objects, extracting issue metadata, and formatting validation results. The suggestion was to "aggressively unify or codeshare" these implementations to abide by the DRY (Don't Repeat Yourself) principle. | ||
|
|
||
| However, sharing utilities across the core ArkType engine and the Standard Schema engine introduces hidden module graph entanglements. Bundlers like Webpack, Rollup, and esbuild often rely on static imports for tree-shaking. A single shared `utils.ts` file imported by both entry points can easily trick the bundler's heuristics into statically tracing the dependency tree back to `arktype`. This would drag the entire 50kb+ ArkType AST engine into the production bundle of users who only wanted to use `arkenv/standard` with Zod. | ||
|
|
||
| ## Decision | ||
|
|
||
| We intentionally duplicate parsing, formatting, and issue-mapping logic across the `arktype` and `standard` engine implementations to maintain an airtight module boundary. **Bundle isolation strictly trumps DRYness across core/standard boundaries.** | ||
|
|
||
| We will not create shared abstractions or utility files that bridge these two domains. The small maintenance cost of duplicated internal logic is a worthwhile trade-off to guarantee that `arkenv/standard` users never incur a bundle size penalty from ArkType. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - The footprint of `@arkenv/standard` remains strictly minimal and fully decoupled from ArkType. | ||
| - Contributors must be aware that fixing a bug in the error extraction logic for ArkType may require a mirrored fix in the Standard Schema logic. | ||
| - Future code reviews raising concerns about DRYness between these files should be directed to this ADR. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.