fix(native): prevent json.isStringify helper mismatch#1997
Merged
Conversation
Validated JSON stringify can traverse a JSON metadata graph that differs from the outer runtime validator, especially when toJSON returns object unions. The serializer now emits and references its own checker helper namespace for branch selection, so generated _su helpers do not depend on validator-only _io helpers. Constraint: Native source ships in the typia npm package, so the package version is bumped. Rejected: Patch generated JavaScript output | codegen must consistently own helper scopes. Rejected: Reuse outer validator helpers | regular and JSON metadata collections can diverge. Confidence: high Scope-risk: narrow Directive: Keep validated stringify checker helpers scoped to the stringify metadata collection. Tested: pnpm format Tested: git diff --cached --check Tested: go test ./cmd/ttsc-typia -run TestJsonIsStringifyScopedCheckerTransform -count=1 Tested: go test ./core/programmers/json ./cmd/ttsc-typia -count=1 Tested: pnpm test:go:native Not-tested: Full pnpm test
c68aac7 to
cf642b1
Compare
The Prefix option is now used by both plain.classify and validated JSON stringify. The comments now describe the caller-owned helper namespace rule instead of a single historical caller. Constraint: Follow-up from self-review of PR #1997. Confidence: high Scope-risk: narrow Tested: pnpm format Tested: git diff --check Tested: go test ./core/programmers/json ./cmd/ttsc-typia -count=1 Not-tested: Full pnpm test
The regression fixture now puts the JSON-only toJSON object union inside a recursive serializer helper and asserts that validated stringify emits its scoped _si helpers before executing both union branches. Constraint: Follow-up from exhaustive self-review of PR #1997. Confidence: high Scope-risk: narrow Tested: gofmt packages/typia/native/cmd/ttsc-typia/json_is_stringify_scoped_checker_transform_test.go Tested: go test ./core/programmers/json ./cmd/ttsc-typia -count=1 Not-tested: Full pnpm test
The scoped checker regression test should follow the cmd/ttsc-typia fixture style used by neighboring transform tests, while still passing the repository's format-go script. Constraint: Self-review found the prior gofmt-only indentation diverged from nearby test files. Confidence: high Scope-risk: narrow Tested: pnpm run format:go Tested: go test ./core/programmers/json ./cmd/ttsc-typia -count=1 Not-tested: Full pnpm test
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
json.isStringifyserializer branch-check helpers to the JSON stringify metadata collection.toJSON()object-union branches that previously emitted missing_io*helper references.typiato13.0.0-rc.2because native source changed.Root Cause
json.isStringifyvalidates with the regular checker collection, then serializes through the JSON stringify collection. When a type definestoJSON(), the JSON metadata graph can contain object-union branches that the outer validator never generated. The validated serializer was still using the default_ichecker helper namespace, so generated serializer helpers could reference validator helpers that did not exist.Changed Behavior
Validated JSON stringify now emits and references checker helpers under its own stringify-local namespace for serializer branch selection. This keeps helper generation tied to the metadata collection that actually needs those helpers instead of relying on the outer validator collection.
Validation
pnpm formatgit diff --cached --checkgo test ./cmd/ttsc-typia -run TestJsonIsStringifyScopedCheckerTransform -count=1go test ./core/programmers/json ./cmd/ttsc-typia -count=1pnpm test:go:nativeLocal Limitations
pnpm testwas not run locally; CI should cover the broader package/test matrix.Fixes #1966