Drop duplicate build_raw copy from CloudBuildCreateBuildOperator - #73592
Merged
Merged
Conversation
shahar1
requested review from
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jason810496,
jscheffl and
potiuk
as code owners
September 23, 2026 06:32
subhramit
suggested changes
Sep 23, 2026
shahar1
force-pushed
the
pr-70794-revive
branch
from
September 23, 2026 07:50
30cad21 to
6ba58e9
Compare
Contributor
|
The test failures seem unrelated. Maybe you can re-run |
potiuk
approved these changes
Sep 23, 2026
prepare_template() now reads self.build instead of the removed build_raw copy, so a second call short-circuits on the already-parsed dict instead of re-reading the build file from disk. Add a test that constructing the operator keeps no second attribute referencing the build argument, and a test that calling prepare_template() twice after the backing file is gone still leaves operator.build populated with the parsed content from the first call. The duplicate-attribute test matches on object identity rather than on the removed build_raw name, so it also catches a copy reintroduced under any other attribute name. The operator leaves template_ext empty, so resolve_template_files() never replaces self.build with the file's contents before prepare_template() runs; prepare_template() is the only place that reads the file, which is what makes the second call idempotent.
potiuk
force-pushed
the
pr-70794-revive
branch
from
September 23, 2026 14:47
6ba58e9 to
e6b2e90
Compare
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.
AI Summary
Supersedes #70794, which went stale. The original commit is preserved as-is with its
author; this branch rebases it onto current
mainand adds the test coverageissue #70296 asks for.
CloudBuildCreateBuildOperatorkept a second copy of the templatedbuildargument inbuild_rawsoprepare_template()could read the un-rendered path.prepare_template()now reads
self.buildand holds the path in a local while it loads the JSON or YAML body,so the constructor only assigns its arguments to their matching fields and the class drops
out of
validate_operators_init_exemptions.txt.The operator leaves
template_extempty, soresolve_template_files()cannot replaceself.buildwith file contents beforeprepare_template()runs — template-loadingbehaviour is unchanged. The second commit covers the two behaviour changes: the
constructor no longer snapshots
build, and a secondprepare_template()call nowshort-circuits on the already-parsed dict instead of re-reading the file.
related: #70296
Validation
uv run --project providers/google pytest providers/google/tests/unit/google/cloud/operators/test_cloud_build.py -q— 38 passedFileNotFoundErroron the secondprepare_template()call)prek run validate-operators-init --all-files— passed (and confirmed the hook flags the pre-change code, so the exemption removal is load-bearing)prek run --from-ref upstream/main --stage pre-commit— passedprek run mypy-providerson both changed files — passedWas generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines
🤖 Generated with Claude Code