Skip to content

Drop duplicate build_raw copy from CloudBuildCreateBuildOperator - #73592

Merged
potiuk merged 2 commits into
apache:mainfrom
shahar1:pr-70794-revive
Sep 23, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
shahar1:pr-70794-revive

Conversation

@shahar1

@shahar1 shahar1 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

AI Summary

Supersedes #70794, which went stale. The original commit is preserved as-is with its
author; this branch rebases it onto current main and adds the test coverage
issue #70296 asks for.

CloudBuildCreateBuildOperator kept a second copy of the templated build argument in
build_raw so prepare_template() could read the un-rendered path. prepare_template()
now reads self.build and 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_ext empty, so resolve_template_files() cannot replace
self.build with file contents before prepare_template() runs — template-loading
behaviour is unchanged. The second commit covers the two behaviour changes: the
constructor no longer snapshots build, and a second prepare_template() call now
short-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 passed
  • Both new tests confirmed to fail against the pre-change operator (FileNotFoundError on the second prepare_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 — passed
  • prek run mypy-providers on both changed files — passed

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

🤖 Generated with Claude Code

@subhramit subhramit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments

Comment thread providers/google/src/airflow/providers/google/cloud/operators/cloud_build.py Outdated
Comment thread providers/google/tests/unit/google/cloud/operators/test_cloud_build.py Outdated
@shahar1 shahar1 removed the backport-to-v3-3-test Backport to v3-3-test label Sep 23, 2026
@shahar1
shahar1 requested a review from subhramit September 23, 2026 08:04

@subhramit subhramit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@subhramit

subhramit commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

The test failures seem unrelated. Maybe you can re-run

abhisek343 and others added 2 commits September 23, 2026 16:47
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
potiuk merged commit b171e3e into apache:main Sep 23, 2026
63 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants