Repository navigation
Description
Note
Currently Stackdriver's monitoring-related operators are being renamed to Cloud Monitoring in #73354.
You may independently implement the fix in Stackdriver's implementation, and I'll get it merged to #73354 before the latter is being merged.
Summary
Make the Cloud Monitoring list operators preserve the hook output when format_ is explicitly set. Currently, format_="dict" and format_="json" both fail with a TypeError.
Background
CloudMonitoringHook.list_alert_policies() and list_notification_channels() already honor format_: "dict" returns dictionaries, "json" returns JSON strings, and None returns protobuf objects. The corresponding operators then unconditionally call AlertPolicy.to_dict() or NotificationChannel.to_dict() on every result. That conversion only accepts protobuf objects, so passing an already-converted dictionary or JSON string raises TypeError.
The operators should return the hook result unchanged when format_ is set. With format_=None, they should continue converting protobuf objects to dictionaries so the value remains XCom-serializable. Update the operator-level format_ documentation to describe this behavior.
Where to look
providers/google/src/airflow/providers/google/cloud/operators/cloud_monitoring.py—CloudMonitoringListAlertPoliciesOperator.executeandCloudMonitoringListNotificationChannelsOperator.execute.providers/google/src/airflow/providers/google/cloud/hooks/cloud_monitoring.py— the existing return-format behavior.providers/google/tests/unit/google/cloud/operators/test_cloud_monitoring.py— unit tests for both operators.
Acceptance criteria
- Both list operators return dictionaries unchanged with
format_="dict". - Both list operators return JSON strings unchanged with
format_="json". - With no
format_, both operators still convert protobuf objects to dictionaries for XCom serialization. - Add focused unit-test coverage for the corrected behavior in both operators.
- Update the operator
format_parameter documentation to accurately state the returned type.
Estimated effort
About 1–2 hours for someone new to the codebase.
Getting started
See Apache Airflow’s contributor quick start.
This issue was drafted with AI assistance and reviewed by a maintainer before filing.
Activity
jinniiii233 commentedon Sep 21, 2026
Hi, I'd like to work on this issue. Could it be assigned to me?
shahar1 commentedon Sep 21, 2026
Hey! As of current policy we do not assign new contributors to issues.
You're welcome to open a PR,
please note that it is currently blocked by #73354 - so it's better to create a PR after the letter is merged.Edit: #73354 does not block, you may implement the fix independently and I'll handle the adjustments.