Skip to content

docs(api): document 403 on permission-gated routes#884

Open
cristim wants to merge 1 commit into
feat/multicloud-web-frontendfrom
fix/476-wave20
Open

docs(api): document 403 on permission-gated routes#884
cristim wants to merge 1 commit into
feat/multicloud-web-frontendfrom
fix/476-wave20

Conversation

@cristim
Copy link
Copy Markdown
Member

@cristim cristim commented May 30, 2026

Closes #476

Summary

  • Adds 403: $ref: '#/components/responses/Forbidden' to 27 operations in internal/api/openapi.yaml whose handlers call requirePermission() but previously only declared 401
  • Routes updated span: dashboard summary/upcoming, config (PUT), config/service (PUT), recommendations (GET + refresh POST), plans (CRUD + createPlannedPurchases), purchases (execute, planned CRUD), purchase details, history (GET/analytics/breakdown), and api-keys (CRUD)
  • Reuses the existing components/responses/Forbidden component (already present in users/groups section)
  • Adds internal/api/openapi_403_test.go: a source-reading regression guard that walks router.go to resolve each route's delegate handler, checks whether it calls requirePermission, and asserts the spec operation declares 403 -- the test fails immediately when a new permission-gated route is added without the matching 403

Test plan

  • go test ./internal/api/ -run TestOpenAPI403OnPermissionGatedRoutes passes
  • go test ./internal/api/... passes (1356 tests)
  • Add a new route calling requirePermission without a 403 in the spec and confirm the test fails

Every operation in openapi.yaml whose handler calls requirePermission
now declares '403: $ref: "#/components/responses/Forbidden"' alongside
the existing 401.  27 operations updated across dashboard, config,
recommendations, plans, planned-purchases, purchases, history, and
api-keys sections.

The components/responses/Forbidden component already existed (used in
the users/groups section); this change wires it consistently across all
remaining permission-gated routes.

Adds openapi_403_test.go: a source-reading regression guard that walks
router.go to map each route's handler wrapper to its delegate h.*
function, then checks whether that function calls requirePermission, and
asserts the spec operation declares 403.  The test fails as soon as a
new permission-gated route is wired in router.go without a matching 403
in the spec.
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/m Days type/docs Documentation labels May 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 minutes and 25 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 232969a5-575b-4c97-811d-db615f94dce2

📥 Commits

Reviewing files that changed from the base of the PR and between 4956d66 and b7d424f.

📒 Files selected for processing (2)
  • internal/api/openapi.yaml
  • internal/api/openapi_403_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/476-wave20

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 30, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Labels

effort/m Days impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/docs Documentation urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant