Keep confidential platform OAuth staging mistakes off Sentry - #1350
Conversation
Throw PlatformOauthAppValidationError for caller-fixable upsert rejects, and re-wrap them as McpCallerError in admin_platform_oauth_app_save so agent enable-without-secret mistakes stay on mcp-event lines instead of opening Sentry triage issues. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
📝 WalkthroughWalkthroughThe PR adds a typed platform OAuth validation error. The admin save handler converts these validation failures into ChangesPlatform OAuth validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
actor Admin as Admin MCP caller
participant SaveHandler as admin-platform-oauth-app-save
participant Upsert as upsertPlatformOauthApp
participant McpError as McpCallerError
Admin->>SaveHandler: Save platform OAuth app
SaveHandler->>Upsert: Upsert OAuth app
Upsert-->>SaveHandler: PlatformOauthAppValidationError
SaveHandler->>McpError: Wrap validation error as caller error
SaveHandler-->>Admin: McpCallerError
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/worker/src/mcp/capabilities/admin/admin-platform-oauth-app-capabilities.node.test.ts`:
- Around line 201-205: Remove the duplicate `.all()` invocation from the
auditSqlite query in the failures initialization, so the prepared statement
calls `.all()` exactly once and its returned array is directly cast to the
expected type.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 966d545a-f4c8-4123-806d-c5108e83c3e7
📒 Files selected for processing (4)
packages/worker/src/integrations/platform-apps.node.test.tspackages/worker/src/integrations/platform-apps.tspackages/worker/src/mcp/capabilities/admin/admin-platform-oauth-app-capabilities.node.test.tspackages/worker/src/mcp/capabilities/admin/admin-platform-oauth-app-save.ts
| const failures = auditSqlite | ||
| .prepare( | ||
| `SELECT action, result FROM audit_events WHERE result = 'failure' ORDER BY id ASC`, | ||
| ) | ||
| .all() as Array<{ action: string; result: string }> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Remove the duplicate .all() call.
Line 205 calls .all() on the array returned by the call above. Array has no .all() method. This prevents the test file from type checking.
Proposed fix
const failures = auditSqlite
.prepare(
`SELECT action, result FROM audit_events WHERE result = 'failure' ORDER BY id ASC`,
)
.all() as Array<{ action: string; result: string }>
- .all() as Array<{ action: string; result: string }>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const failures = auditSqlite | |
| .prepare( | |
| `SELECT action, result FROM audit_events WHERE result = 'failure' ORDER BY id ASC`, | |
| ) | |
| .all() as Array<{ action: string; result: string }> | |
| const failures = auditSqlite | |
| .prepare( | |
| `SELECT action, result FROM audit_events WHERE result = 'failure' ORDER BY id ASC`, | |
| ) | |
| .all() as Array<{ action: string; result: string }> |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@packages/worker/src/mcp/capabilities/admin/admin-platform-oauth-app-capabilities.node.test.ts`
around lines 201 - 205, Remove the duplicate `.all()` invocation from the
auditSqlite query in the failures initialization, so the prepared statement
calls `.all()` exactly once and its returned array is directly cast to the
expected type.
|
🔎 Preview deployed: https://kody-pr-1350.kody-a99.workers.dev Worker: Mocks:
|
What
Follow-up to #1345 / Sentry KODY-CLOUDFLARE-4G: classify caller-fixable
upsertPlatformOauthApprejects asPlatformOauthAppValidationError, and re-wrap them asMcpCallerErrorinadmin_platform_oauth_app_save.Why
The single production event was an agent enabling a confidential platform app without a client secret (release before #1345). Staging without a secret while
enabled: falsealready works; enabling without a secret is still a valid reject, but it must not open Sentry issues that look like platform bugs and trip triage.Testing
PlatformOauthAppValidationErrorMcpCallerErrorfor enable-without-secret (default and staged→enable)System recap — composes existing primitives (low risk)
Mode: recap · Base:
main@9faafa09· Head:307b0445Classification: composes — wires the existing
McpCallerError/ caller-failure observability path onto platform OAuth app input validation; no new primitives or auth semantics.Primitives touched
integrationsrbacMcpCallerErrorSystem map
Admin MCP save validates platform OAuth apps and keeps staging mistakes off Sentry.
Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).
Summary by CodeRabbit