You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ylv01 (via GitHub)" <gi...@apache.org> on 2026/09/21 09:18:18 UTC

[PR] Fix Stackdriver list operators with explicit output formats [airflow]

ylv01 opened a new pull request, #73434:
URL: https://github.com/apache/airflow/pull/73434

   Explicit `format_="dict"` and `format_="json"` currently fail because both Stackdriver list operators attempt to convert the hook's already-formatted output as protobuf objects. Preserve that output unchanged when `format_` is set, and retain protobuf-to-dictionary conversion when it is `None` for XCom serialization.
   
   Update both operator docstrings and add parametrized regression tests for both explicit formats. The existing default-format tests remain unchanged.
   
   Closes #73431.
   
   This targets the current Stackdriver implementation independently of the rename in #73354, as allowed in the issue.
   
   Validation passed in [Linux Breeze CI](https://github.com/ylv01/airflow/actions/runs/35580061477):
   
   - Regular and manual prek checks on both changed files, including provider type checks.
   - Complete Stackdriver operator and hook unit-test files.
   - Regression verification: reverting only the operator fix makes all four new cases fail.
   - Breeze selective checks.
   
   The unit tests and regression verification also passed in an [independent run](https://github.com/ylv01/airflow/actions/runs/35580894759). Local Ruff formatting/linting and `git diff --check` passed. Local Breeze testing was blocked by missing Docker on Windows, so the test and check suites ran on Linux. Verification workflows live only on separate fork branches and are not part of this PR.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — OpenAI Codex (GPT-6)
   
   Generated-by: OpenAI Codex (GPT-6) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Stackdriver list operators with explicit output formats [airflow]

Posted by "ylv01 (via GitHub)" <gi...@apache.org>.
ylv01 commented on code in PR #73434:
URL: https://github.com/apache/airflow/pull/73434#discussion_r4061081062


##########
providers/google/src/airflow/providers/google/cloud/operators/stackdriver.py:
##########
@@ -147,7 +146,9 @@ def execute(self, context: Context):
             context=context,
             project_id=self.project_id or self.hook.project_id,
         )
-        return [AlertPolicy.to_dict(policy) for policy in result]
+        if self.format_ is None:

Review Comment:
   Thanks for catching this compatibility edge case. Applied the suggested condition to both operators in aa4e3aa, updated the docstrings, and added six regression cases covering "Dict", "protobuf", and the empty string across both operators.
   
   ---
   Drafted-by: OpenAI Codex (GPT-6) (no human review before posting)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Stackdriver list operators with explicit output formats [airflow]

Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on code in PR #73434:
URL: https://github.com/apache/airflow/pull/73434#discussion_r4060762449


##########
providers/google/src/airflow/providers/google/cloud/operators/stackdriver.py:
##########
@@ -147,7 +146,9 @@ def execute(self, context: Context):
             context=context,
             project_id=self.project_id or self.hook.project_id,
         )
-        return [AlertPolicy.to_dict(policy) for policy in result]
+        if self.format_ is None:

Review Comment:
   The hook branches on the *value* of `format_`, not on whether it is set: `"dict"` returns dictionaries, `"json"` returns JSON strings, and **anything else** falls through to `return policies_` — the raw protobuf pager.
   
   So with e.g. `format_="Dict"` (a typo) or `format_="protobuf"` (which the old docstring arguably invited), this now returns the pager straight to XCom, where it isn't serializable — before this change it was converted to dictionaries. Mirroring the hook's own branch keeps every input XCom-safe:
   
   ```suggestion
           if self.format_ not in ("dict", "json"):
   ```
   



##########
providers/google/src/airflow/providers/google/cloud/operators/stackdriver.py:
##########
@@ -578,7 +578,9 @@ def execute(self, context: Context):
             context=context,
             project_id=self.project_id or self.hook.project_id,
         )
-        return [NotificationChannel.to_dict(channel) for channel in channels]
+        if self.format_ is None:

Review Comment:
   Same as above for the notification-channels operator: the hook falls through to the protobuf pager for any `format_` that isn't `"dict"` or `"json"`, so this returns a non-XCom-serializable pager where the old code returned dictionaries.
   
   ```suggestion
           if self.format_ not in ("dict", "json"):
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Stackdriver list operators with explicit output formats [airflow]

Posted by "ylv01 (via GitHub)" <gi...@apache.org>.
ylv01 commented on PR #73434:
URL: https://github.com/apache/airflow/pull/73434#issuecomment-5760967708

   I also went through the updated diff manually and verified the new regression tests. Thanks again, @shahar1, for catching this compatibility edge case.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Cloud Monitoring list operators with explicit output formats [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #73434:
URL: https://github.com/apache/airflow/pull/73434#issuecomment-5778492645

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Stackdriver list operators with explicit output formats [airflow]

Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on PR #73434:
URL: https://github.com/apache/airflow/pull/73434#issuecomment-5763574791

   > I also went through the updated diff manually and verified the new regression tests. Thanks again, @shahar1, for catching this compatibility edge case.
   
   Please fix static checks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Cloud Monitoring list operators with explicit output formats [airflow]

Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 merged PR #73434:
URL: https://github.com/apache/airflow/pull/73434


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Stackdriver list operators with explicit output formats [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #73434:
URL: https://github.com/apache/airflow/pull/73434#issuecomment-5758162585

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our [Contributors' Guide](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example Dag that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org