Skip to content

monitoring: clarify comparison enum doc for alert policy (#16862)#17496

Open
jbbqqf wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
jbbqqf:feat/16862-monitoring-comparison-docs
Open

monitoring: clarify comparison enum doc for alert policy (#16862)#17496
jbbqqf wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
jbbqqf:feat/16862-monitoring-comparison-docs

Conversation

@jbbqqf
Copy link
Copy Markdown

@jbbqqf jbbqqf commented May 9, 2026

Summary

Documentation fix on google_monitoring_alert_policy. The Cloud Monitoring API only supports COMPARISON_LT and COMPARISON_GT for condition_threshold.comparison and conditions[].condition_sql.row_count_test.comparison, but the registry docs presents all six enum values without clearly flagging the API limitation, so users set COMPARISON_GE (and friends) and get an API error back.

Fixes hashicorp/terraform-provider-google#16862 — see hashicorp/terraform-provider-google#16862

Why

The maintainer (shuyama1) acknowledged this in 2023:

Sorry for the misleading documentation. Looks like the API only supports COMPARISON_LT and COMPARISON_GT currently (API doc). We'll correct the documentation for available values.

…but the doc cleanup was never shipped. Users continue to hit the same trap (the latest comment on the issue, with screenshot, is from 2025).

This PR rewords the field descriptions to lead with the API limitation and link the canonical reference, so the registry doc is unambiguous. The enum value list is intentionally left intact so already-imported state that happens to contain non-LT/GT values doesn't error out at parse time; the API remains the authoritative gate.

GCP API reference:

What changed

mmv1 source — single file:

 mmv1/products/monitoring/AlertPolicy.yaml | 27 +++++++++++++++++----------

Two comparison field descriptions are reworded:

  • conditions[].condition_threshold.comparison
  • conditions[].condition_sql.row_count_test.comparison

The downstream impact after regeneration is registry-doc text only — Description strings on the schema. No validation change, no plan/apply behavior change.

Edge cases tested

# Scenario HCL excerpt Expected Verified by
1 LT/GT (supported) comparison = "COMPARISON_LT" Plan + apply succeed (unchanged from today) static — no path change
2 GE/LE/EQ/NE (unsupported) comparison = "COMPARISON_GE" Plan succeeds (validation passes), API returns the same error as today static — enum_values list intentionally kept
3 Imported state with non-LT/GT value preexisting tfstate with COMPARISON_GE Plan/refresh does not error at parse time enum_values list intentionally kept

Test protocol

Test Result Notes
YAML well-formedness review pass both comparison blocks rewritten consistently
API premise confirmed linked Monitoring REST docs and maintainer ack

This is a doc-only change (description text). No live smoke was run because the change does not alter plan/apply behavior, validation, or payload shape — it only changes the doc string surfaced in the registry. The reviewer can compare before/after by re-rendering the registry doc page from the regenerated provider.

Resources

Release notes

Disclosure

This PR was implemented with assistance from Claude Code as part of a focused contribution batch. The diff was reviewed manually against the GCP API documentation linked above. The author (a human) reviewed the diff and the API-premise check before opening this PR.

…Platform#16862)

The Cloud Monitoring API only supports COMPARISON_LT and COMPARISON_GT
for MetricThreshold conditions and SqlCondition row-count tests, but
the schema description merely tacked that information on at the end of
a long paragraph; the registry doc still leads with all six possible
values, surprising users who set COMPARISON_GE and get an API error
back.

Reword the descriptions for both `condition_threshold.comparison` and
`condition_sql.row_count_test.comparison` to lead with the API
limitation and link to the canonical reference. Leave the enum_values
list untouched so existing imported state with non-LT/GT values keeps
parsing — the API itself remains the authoritative gate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label May 9, 2026
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot requested a review from shuyama1 May 9, 2026 09:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@shuyama1, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to create an alert policy with COMPARISON_GE

2 participants