Skip to content

fix: build a model before reading its field annotations when pruning extra fields - #3008

Merged
copybara-service[bot] merged 1 commit into
mainfrom
copybara/988508356
Sep 25, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
copybara/988508356

Conversation

@copybara-service

Copy link
Copy Markdown

fix: build a model before reading its field annotations when pruning extra fields

_remove_extra_fields walks a response against a model's
model_fields[...].annotation to find the nested model to recurse into. Models
build on first use, and an unbuilt model's annotations still hold the forward
references they were declared with, so the walk can hand a bare 'Part' string
to the next level and fail with AttributeError: 'str' object has no attribute 'model_fields'. Build the model first; that costs nothing extra, because the
caller validates against the same model immediately afterwards.

@copybara-service
copybara-service Bot force-pushed the copybara/988508356 branch 3 times, most recently from 888a03a to 6f70b5b Compare September 25, 2026 22:58
…extra fields

`_remove_extra_fields` walks a response against a model's
`model_fields[...].annotation` to find the nested model to recurse into. Models
build on first use, and an unbuilt model's annotations still hold the forward
references they were declared with, so the walk can hand a bare `'Part'` string
to the next level and fail with `AttributeError: 'str' object has no attribute
'model_fields'`. Build the model first; that costs nothing extra, because the
caller validates against the same model immediately afterwards.

PiperOrigin-RevId: 988545915
@copybara-service
copybara-service Bot merged commit 7845acd into main Sep 25, 2026
1 check passed
@copybara-service
copybara-service Bot deleted the copybara/988508356 branch September 25, 2026 23:02

This branch was successfully deployed

1 active deployment
github-pages — 7845acd5 Deployed Sep 25, 2026 by github-pages[bot] via deploy #1487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant