fix: copy typed fields to additional_properties in build_from_hash#3500
Draft
charlie-zhang109 wants to merge 1 commit into
Draft
fix: copy typed fields to additional_properties in build_from_hash#3500charlie-zhang109 wants to merge 1 commit into
charlie-zhang109 wants to merge 1 commit into
Conversation
build_from_hash (used by the API client deserializer) only routed unknown fields to additional_properties; typed fields were set via their accessors but never mirrored into the AP hash. initialize() already has the per-field copy, but build_from_hash calls new() with no args so that copy ran against an empty attributes hash. Add a loop in build_from_hash that copies each typed field that was present in the JSON attributes into additional_properties after deserialization, matching the behaviour of initialize(). Applied to both v1 and v2 model_base.rb. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
build_from_hash(the path used by the API client deserializer) set typed fields via their accessors but never mirrored them intoadditional_propertiesinitialize()has an explicit per-field copy at the end, butbuild_from_hashcallsnew()with no args, so that copy runs against an empty attributes hash and copies nothingx-keep-typed-in-additional-properties, this meant typed fields were invisible inadditionalPropertiesafter a real API call, even though they appeared correctly when the model was constructed directly vianew(attributes)Root cause
BaseGenericModel#build_from_hashin both v1 and v2model_base.rbrouted unknown fields to AP but had no equivalent step for typed fields:Fix
After deserialization, loop over
openapi_typesand copy each typed field that was present in the JSON into AP, matching whatinitialize()already does:Applied to both
v1/model_base.rbandv2/model_base.rb.Test plan
UsageSummaryResponseintegration tests (bundle exec ruby usage_summary_integration_test.rb -v) — the 3 "missing from additionalProperties" failures forcustom_live_ts_sum,synthetics_check_calls_count_sum, andcustom_live_ts_avgare resolved🤖 Generated with Claude Code