Skip to content

feat(monitor): use the versioned monitor API and drop experimental - #91

Open
sfc-gh-dlotfi wants to merge 2 commits into
mainfrom
dlotfi/monitor-versioned-crud
Open

sfc-gh-dlotfi wants to merge 2 commits into
mainfrom
dlotfi/monitor-versioned-crud

Conversation

@sfc-gh-dlotfi

Copy link
Copy Markdown
Contributor

Refs OB-69679. First of three PRs: this one is the versioned CRUD; monitor actions and unmute, then preview, follow.

What

  • monitor view, create, update, delete, enable and disable send Observe-Api-Version: 2026-10-06 and use the generated MonitorResource, MonitorCreateRequest and MonitorUpdateRequest.
  • On a 403 (account without MonitorV2.restCrudApi), view, delete, enable and disable fall back to the unversioned request, as monitor list does.
  • create and update choose by file shape. A definition or actionRules key is the legacy shape and goes unversioned (works everywhere). Any other file is versioned; a 403 on it reports that the versioned API is not enabled, because a versioned body cannot be converted to the legacy one.
  • Masking: ***REDACTED*** prints as it came and is sent back unchanged on update, so the server keeps the stored value. create refuses a file holding a mask, since the API says a create cannot save one. Help text says so.
  • update no longer lets an id inside the file override the id argument.
  • list, view, create, update, delete, enable and disable lose experimental: true. README and AGENTS.md list them.

Notes

  • The 403 gate answers type forbidden, not feature_not_enabled, so the fallback keys on the status like list does; the legacy request then reports a real permission error itself.
  • Types were generated from a spec bundled from monorepo master (internal bundle), since the CI spec secret is not available locally. CI regenerates from the real one.
  • No integration test: there is none for monitors today and it needs a live tenant.

Tests

bun test src/commands/monitor src/rest/monitor: 147 pass. New cases cover the versioned header, the 403 fallback for get, delete, enable/disable and update, the versioned-only 403 error on create and update, non-403 errors not falling back, masked values on view, update and create.

🤖 Generated with Claude Code

view, create, update, delete, enable and disable send
Observe-Api-Version 2026-10-06 and use the generated MonitorResource,
MonitorCreateRequest and MonitorUpdateRequest. On a 403 (the account does
not have MonitorV2.restCrudApi yet) get, delete, enable and disable fall
back to the unversioned request, as list does. create and update pick the
request from the file: a definition or actionRules key is the legacy shape
and goes unversioned; any other file is versioned, and a 403 on it says the
versioned API is not enabled instead of retrying a body that cannot convert.

Masked values (***REDACTED***) print as they came and are sent back
unchanged on update, so the server keeps the stored value. create refuses a
file that holds one, since a create cannot save a mask.

list, view, create, update, delete, enable and disable are no longer
experimental. README and AGENTS.md list them.

Refs OB-69679

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@orca-security-us orca-security-us Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed OSS Licenses high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Malicious Packages high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

This PR touches 63 CLI command surface(s), 7 with a contract change. Advisory only: nothing is gated yet; under the eval gate each would need eval coverage.

Command Change Tags
observe monitor create modified contract
observe monitor delete modified contract
observe monitor disable modified contract
observe monitor enable modified contract
observe monitor list modified contract
observe monitor update modified contract
observe monitor view modified contract
observe alert list modified indirect
observe alert view modified indirect
observe apm environment list modified indirect
observe apm invocation-graph modified indirect
observe apm service list modified indirect
observe cli upgrade modified indirect
observe dashboard create modified indirect
observe dashboard delete modified indirect
observe dashboard list modified indirect
observe dashboard update modified indirect
observe dashboard view modified indirect
observe dataset list modified indirect
observe dataset view modified indirect
… 43 more

The versioned-to-legacy fallback now triggers only when the 403 is the
feature gate (type feature_not_enabled, or the gate's "currently not
accessible" message). A permission 403 is shown as it is instead of being
retried on the legacy endpoint.

update refuses a legacy-shaped file that holds ***REDACTED***, since the
legacy endpoint would save the mask as the value.

updateMonitor takes the patch as its own argument, so file keys never reach
the SDK call. README notes that view --json prints the native shape on
accounts with the versioned API.

Refs OB-69679

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sfc-gh-dlotfi
sfc-gh-dlotfi marked this pull request as ready for review December 4, 2026 22:39

@observe-baby-bots observe-baby-bots Bot 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.

Automated Code Review

Summary

Moves monitor view, create, update, delete, enable and disable to the versioned monitor API (Observe-Api-Version: 2026-10-06) and the generated MonitorResource/MonitorCreateRequest/MonitorUpdateRequest types. When the account's feature gate is closed (a 403 of type feature_not_enabled or one whose message contains "currently not accessible"), view, delete, enable, disable and shared-key updates fall back to the unversioned request. Create and update pick the request from the file's shape: a definition or actionRules key means the legacy shape. Files that hold the ***REDACTED*** mask are refused on create and on a legacy-shape update, and are passed through on a versioned update so the server keeps the stored secret. The experimental flag comes off all seven monitor commands, and the help text, README and AGENTS.md are updated.

Problem fit: solves — Move monitor view/create/update/delete/enable/disable to the versioned monitor API with a 403 legacy fallback, handle masked secrets, and drop experimental.

Not needed for the stated problem
  • src/lib/format-error.ts: any 403 whose text contains 'currently not accessible' now maps to the generic not-enabled message for every command
Suggested review order — 5 stop(s)
  1. src/rest/monitor/versioned.ts:25

    Core: shape detection (isLegacyBody, isVersionedOnlyBody) and withLegacyFallback. Every command routes through these.

  2. src/lib/format-error.ts:46

    Gate detection: fallback keys on a message substring, and the change affects formatApiError for every REST command. Check its scope and how brittle it is.

  3. src/rest/monitor/update-monitor.ts:48

    Three-way choice: legacy, versioned with fallback, or versioned-only error. Check that shared-key patches fall back and others report not-enabled.

  4. src/commands/monitor/update.ts:72

    Command layer: mask refusal for legacy files and patch shaping. A versioned file is sent whole as a merge patch.

  5. src/commands/monitor/view.ts:127

    Consumer: new versioned text view. Object.keys on sharedActions/inlineActions assumes both are always present.


Risk: high (floor high, model medium)
  • Removing experimental exposes the commands by default to accounts that rely on the legacy fallback
  • The fallback depends on the server's 403 text "currently not accessible" in isFeatureNotEnabled
  • update/create send whole versioned files and rely on the server ignoring read-only fields
Review effort: high (floor high, model high)
  • 27 files, ~570 non-test lines across the command and REST layers
  • Two body shapes, mask policy and fallback rules interact in create, update and updateMonitor
  • Server behaviour (gate wording, merge-patch semantics, masks) cannot be checked from the client code
Review by aspect — 0 finding(s) in 0 aspect(s), 27 file(s) analyzed, 0 inline comment(s)
  • ✅ Bug Detection — 0 found, 2 below threshold
  • ✅ Security — no issues
  • ✅ Design — 0 found, 1 below threshold
  • ✅ Performance — no issues
  • ✅ Error Handling — 0 found, 1 below threshold
  • ✅ Maintainability — 0 found, 3 below threshold
  • ✅ Test Coverage — no issues
  • ✅ Project Standards — no issues

Analyzed 27 file(s). Posted 0 inline comment(s).

@observe-baby-bots observe-baby-bots Bot added risk:high Code review bot: high risk review-effort:high Code review effort: high labels Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-effort:high Code review effort: high risk:high Code review bot: high risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant