-
Notifications
You must be signed in to change notification settings - Fork 274
fix(typescript): filter out processed raw keys in passthrough schema #11466
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
Open
jsklan
wants to merge
8
commits into
main
Choose a base branch
from
devin/1767896836-ts-passthrough-additional-properties
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(typescript): filter out processed raw keys in passthrough schema #11466
jsklan
wants to merge
8
commits into
main
from
devin/1767896836-ts-passthrough-additional-properties
Conversation
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
…trating wire test failure with additionalProperties Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…nal-properties fixture Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
…-passthrough-additional-properties fixture Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
…t to show expected result Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
…hrough-additional-properties Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
When an OpenAPI schema has additionalProperties: true, the passthrough() method was spreading all raw properties first, then spreading transformed properties. This caused both snake_case (raw) and camelCase (transformed) versions of properties to appear in the deserialized response. The fix filters the raw object to only include keys that are NOT in the schema's raw properties list before spreading, so only truly additional properties pass through. Also removes ts-passthrough-additional-properties from allowedFailures since it now passes. Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
…perties Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
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.
Description
Refs: SDK Generation Bug Fix workflow (steps 1 and 2 of 3)
This PR adds a minimal seed test fixture that reproduces a wire test failure in the TypeScript SDK when using
additionalProperties: truein OpenAPI schemas with the serialization layer enabled, and includes the manual fix showing the expected generated output.Link to Devin run (step 1): https://app.devin.ai/sessions/5880724094f6499a8d50c183dcd924f0
Link to Devin run (step 2): https://app.devin.ai/sessions/2d09f0fdb5fb48c2b2301ce956b3c44d
Requested by: @jsklan
Changes Made
ts-passthrough-additional-propertiesintest-definitions/fern/apis/seed/ts-sdk/seed.ymlwithnoSerdeLayer: falseallowedFailuresinseed/ts-sdk/seed.ymlfor CI to passsrc/core/schemas/builders/object/object.tsto show expected behaviorManual Fixes Applied (Step 2)
File changed:
seed/ts-sdk/ts-passthrough-additional-properties/src/core/schemas/builders/object/object.tsWhat was fixed: The
passthrough()method in the object schema was spreading all raw properties first, then spreading transformed properties. This caused both snake_case (raw) and camelCase (transformed) versions of properties to appear in the result.The fix: Filter out raw properties that were already processed before spreading, so only truly additional properties pass through:
Note: The initial fix attempt using
filterObject()caused TypeScript compilation errors due to type constraints. The manual loop approach with explicit type assertion resolves this.Handoff Context (for next session - Step 3)
Bug Summary: When an OpenAPI schema has
additionalProperties: true, the generated serialization layer uses.passthrough()which causes both camelCase and snake_case versions of properties to appear in the deserialized response.Key insight: The
passthrough()method spreadsrawfirst (containing snake_case keys likeuser_name), then spreadstransformed.value(containing camelCase keys likeuserName). The fix is to filterrawto only include keys that are NOT in the schema's raw properties list before spreading.Files to investigate in generator:
generators/typescript/utils/core-utilities/src/core/schemas/builders/object/object.ts- The source file for thepassthrough()method (lines 272-312). This needs the same fix applied.generators/typescript/model/type-schema-generator/src/object/GeneratedObjectTypeSchemaImpl.ts- Where.passthrough()is called whenthis.shape.extraPropertiesis true (lines 41-43).Validation command:
pnpm seed:local test --generator ts-sdk --fixture ts-passthrough-additional-propertiesTesting
pnpm buildpasses (both CJS and ESM)allowedFailuresfor CIHuman Review Checklist
object.tscorrectly filters out processed raw keysas Parsed & { [key: string]: unknown }is safejsonmethod still uses...(parsed as any)- may need similar fix in step 3