analytics-api: register routes via toolkit OperationBuilder - #1506
Conversation
Replace the raw `axum::Router::route` chain (21 endpoints) with the gears-rust toolkit `OperationBuilder`, so every route records an OpenAPI OperationSpec plus auth/license metadata in one place — the framework idiom used by api-gateway and the gears under gears-rust/gears. Scope is handler-registration only: the builder is driven standalone against a local OpenApiRegistryImpl, and main.rs keeps serving the resulting axum::Router. AppState, every handler signature, and the tenant_middleware layer are unchanged. Serving /openapi.json and the full bootstrap-host/gear migration are tracked in constructorfabric#1505. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Anton Zelenov <antonz@constructor.tech>
|
Warning Review limit reached
More reviews will be available in 6 minutes and 6 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe analytics API crate now depends on ChangesAnalytics API Router Migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 `@src/backend/services/analytics-api/src/api/mod.rs`:
- Around line 302-309: The `/health` route is marked public in the router, but
that only affects docs and does not bypass runtime auth, so requests still hit
`tenant_middleware` and fail without X-Insight-Tenant-Id. Update the middleware
in `tenant_middleware` to explicitly skip tenant validation for the `/health`
path, or remove `/health` from the middleware-wrapped routes so
`handlers::health` can respond unauthenticated as intended.
🪄 Autofix (Beta)
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
Run ID: 96289829-fb6a-4e0c-ae17-3736be401ae9
⛔ Files ignored due to path filters (1)
src/backend/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
src/backend/services/analytics-api/Cargo.tomlsrc/backend/services/analytics-api/src/api/mod.rs
Two fixes for PR constructorfabric#1506: - Dockerfile: install protobuf-compiler in the builder stage. Depending on `toolkit` non-optionally pulls cf-gears-system-sdks (directory/gRPC), whose build script needs protoc; the builder image lacked it so the release build failed with exit 101. Mirrors the api-gateway Dockerfile. - api/mod.rs: register /health on a separate router merged AFTER the tenant middleware layer, so it stays off the tenant-scoped path. k8s liveness/ readiness probes hit /health directly on the pod with no X-Insight-Tenant-Id header; routing it through tenant_middleware would 400 every probe on a multi-tenant install (no tenant_default_id). Mirrors the gears-rust api-gateway host, which serves /health on its own top-level router and marks it public rather than routing it through per-request auth. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Anton Zelenov <antonz@constructor.tech>
Replace the raw
axum::Router::routechain (21 endpoints) with the gears-rust toolkitOperationBuilder, so every route records an OpenAPI OperationSpec plus auth/license metadata in one place — the framework idiom used by api-gateway and the gears under gears-rust/gears.Scope is handler-registration only: the builder is driven standalone against a local OpenApiRegistryImpl, and main.rs keeps serving the resulting axum::Router. AppState, every handler signature, and the tenant_middleware layer are unchanged. Serving /openapi.json and the full bootstrap-host/gear migration are tracked in #1505.
Summary by CodeRabbit