Validate Cloud Function deploy body after template rendering - #70531
Open
mitre88 wants to merge 1 commit into
Open
Validate Cloud Function deploy body after template rendering#70531mitre88 wants to merge 1 commit into
mitre88 wants to merge 1 commit into
Conversation
The operator's body, location, and api_version are template fields, but the operator validated the body, preprocessed the zip path, and built the field validator in __init__. A fully templated body crashed at parse time inside ZipPathPreprocessor, and the validator was pinned to the un-rendered api_version. All of it now happens at the start of execute(), against rendered values. Part of the burn-down tracked in apache#70296.
mitre88
requested review from
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jason810496,
jscheffl,
potiuk and
shahar1
as code owners
July 27, 2026 15:36
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.
Part of the template-field validation burn-down tracked in #70296.
CloudFunctionDeployFunctionOperatorlistsbody,location, andapi_versionintemplate_fields, but__init__validated the body, ranZipPathPreprocessor.preprocess_body()(which both validates and mutates the body), and constructedGcpBodyFieldValidatorpinned to the un-renderedapi_version. A fully templatedbodycrashed withAttributeErrorat parse time inside the preprocessor. All of this now runs at the start ofexecute()against the rendered values.The missing-
location/bodytruthiness checks and the zip-path exclusivity rules depend on rendered values (an expression rendering to an empty string must count as missing), so per the discussion in #70505 these are genuine value reads, not provision checks.Tests: converted the four construction-time raise tests to execute-time, and added
test_templated_body_deploys_after_rendering, which constructs the operator with a templatedbody(previously a parse-time crash) and deploys once the field holds the rendered value — it fails against the previous implementation. The class is removed from the exemption list and thevalidate-operators-initcheck passes locally.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Fable 5) following the guidelines