Skip to content

fix: middleware for multi-tenant#1719

Merged
nikhilsinhaparseable merged 1 commit into
parseablehq:mainfrom
nikhilsinhaparseable:fix/middleware
Jul 9, 2026
Merged

fix: middleware for multi-tenant#1719
nikhilsinhaparseable merged 1 commit into
parseablehq:mainfrom
nikhilsinhaparseable:fix/middleware

Conversation

@nikhilsinhaparseable

@nikhilsinhaparseable nikhilsinhaparseable commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
  • add x-p-tenant header only for multi-tenant deployment
  • extract tenant id from x-p-tenant (if api key user sends) or intra-cluster-tenant (prism forwards to queriers)
  • tenant id to default for single tenant deployment

Summary by CodeRabbit

  • Bug Fixes
    • Improved tenant handling during request authentication so tenant information is derived more reliably from supported headers.
    • Adjusted API-key session handling to restore tenant context only in multi-tenant deployments.
    • Standardized single-tenant API-key lookup to use the default tenant consistently.

- add `x-p-tenant` header only for multi-tenant deployment
- extract tenant id from `x-p-tenant` (if api key user sends)
or `intra-cluster-tenant` (prism forwards to queriers)
- tenant id to default for single tenant deployment
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f45bd265-080e-415d-a21c-5f539e1f7857

📥 Commits

Reviewing files that changed from the base of the PR and between d0390ce and c1be1bf.

📒 Files selected for processing (1)
  • src/handlers/http/middleware.rs

Walkthrough

Tenant identification in AuthMiddleware now also falls back to the intra-cluster-tenant header (excluding DEFAULT_TENANT). Reinsertion of the TENANT_ID header after API-key session creation is now conditional on multi-tenant mode. In find_api_key_user, single-tenant lookups always use DEFAULT_TENANT rather than an optional tenant_id hint.

Changes

Tenant Header Resolution

Layer / File(s) Summary
Tenant id capture and conditional header reinsertion
src/handlers/http/middleware.rs
Tenant id derivation falls back to the intra-cluster-tenant header (excluding DEFAULT_TENANT), and the TENANT_ID header is reinserted after API-key session setup only when multi-tenant mode is active.
Single-tenant lookup default
src/handlers/http/middleware.rs
find_api_key_user's single-tenant branch now always resolves to DEFAULT_TENANT instead of using a passed-in tenant_id hint when present.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: parmesant

Poem

A tenant hopped through headers new,
DEFAULT_TENANT filtered from view,
Multi-tenant mode gets its due,
Single-tenant keeps its lane too,
Hoppy code, reviewed and true! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and misses the required issue reference, Description section, rationale, and checklist items. Add the Fixes #XXXX line, a Description section with goal/rationale/key changes, and complete the testing/comments/docs checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and related to the multi-tenant middleware auth changes, though it is a bit broad.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@nikhilsinhaparseable nikhilsinhaparseable merged commit 47cff47 into parseablehq:main Jul 9, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants