-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Validate Google operator templated parameters after rendering #70534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
| from collections.abc import Sequence | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from airflow.providers.common.compat.sdk import AirflowException | ||
| from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID | ||
| from airflow.providers.google.firebase.hooks.firestore import CloudFirestoreHook | ||
| from airflow.providers.google.version_compat import BaseOperator | ||
|
|
@@ -78,14 +77,14 @@ def __init__( | |
| self.project_id = project_id | ||
| self.gcp_conn_id = gcp_conn_id | ||
| self.api_version = api_version | ||
| self._validate_inputs() | ||
| self.impersonation_chain = impersonation_chain | ||
|
|
||
| def _validate_inputs(self) -> None: | ||
| if not self.body: | ||
| raise AirflowException("The required parameter 'body' is missing") | ||
| raise ValueError("The required parameter 'body' is missing") | ||
|
|
||
| def execute(self, context: Context): | ||
| self._validate_inputs() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the move I'd like to reconsider — and it's the same question
The two stated reasons both bite here: with #70505 — which you cite above — is the PR that narrowed the hook to permit this check in the constructor, not to require moving it. Five merged PRs already made this move and are queued for revert in #70503. The rendered-value gap you're fixing is real, though. #70296's answer is to have both: "a provision check in One trap if you do rewrite the constructor copy: #70505 warns that turning a required-argument check into Drafted-by: Claude Code (Opus 5); reviewed by @shahar1 before posting |
||
| hook = CloudFirestoreHook( | ||
| gcp_conn_id=self.gcp_conn_id, | ||
| api_version=self.api_version, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaxil Because
bodyis a template field, soif not self.bodyin__init__reads the unrendered value: a Jinja template string like"{{ ti.xcom_pull(...) }}"is always truthy at construction time, so the check can never catch a body that renders empty — and per the template-field validation burn-down (#70296), value checks on templated parameters belong after rendering. Moving the call toexecute()validates the rendered value. (An argument-provision check would stay in__init__per #70505, butnot self.bodyis a truthiness/value check, which is exactly the kind that must move.)Same rationale for the
speech_to_text/text_to_speechchanges in this PR.Drafted-by: Claude Code (Fable 5) (no human review before posting)