Skip to content

fix: format Symbol paths in validation errors - #1304

Open
FanWu-ai wants to merge 1 commit into
ianstormtaylor:mainfrom
FanWu-ai:fix-symbol-validation-paths-20261012
Open

FanWu-ai wants to merge 1 commit into
ianstormtaylor:mainfrom
FanWu-ai:fix-symbol-validation-paths-20261012

Conversation

@FanWu-ai

Copy link
Copy Markdown

Validating a Map with a Symbol key and an invalid value throws a native TypeError while formatting path.join('.'), before StructError can be returned. This also makes is() throw instead of returning false for that invalid value.

Convert only Symbol path components to text when constructing the message. Keep the original Symbol identities in failure paths and keys, and preserve existing formatting for ordinary path components. Add eight tests covering structured errors, boolean validation, nested paths, custom messages and valid-map compatibility.

Validation on Linux / Node 24.19.0 and 22.19.0:

  • Fresh pristine full npm test: 225 tests; final: 233 tests on both runtimes. Builds and source/test type checks pass. npm run lint passes.
  • Exact added cases against original source: seven fail with native TypeError and one control passes.
  • Independent automated review reran all required gates and checked 444 additional ESM/CommonJS cases, including raw Symbol identity preservation and ordinary-key controls.
  • git diff --check passes; no dependency or lockfile changes.

The reused dependency tree retains the previously documented expect@29.7 resolution permitted by @types/expect's wildcard, compatible with the repository's TypeScript 4 toolchain. No new downgrade was made; a fresh unpinned CI install may resolve differently. Other runtime/platform and hosted results are not claimed.

This differs from #1135's Symbol-value printing change; it fixes Symbol components of error paths. Prepared and tested with OpenAI Codex assistance; no human review is claimed.

Convert Symbol path components only for error-message formatting while
preserving raw path and key identities in structured failures.

AI assistance: OpenAI Codex.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant