Skip to content

Select organization and cluster with ID headers - #107

Open
jordiori wants to merge 7 commits into
mainfrom
jordiori/cli-org-cluster-id-headers
Open

jordiori wants to merge 7 commits into
mainfrom
jordiori/cli-org-cluster-id-headers

Conversation

@jordiori

@jordiori jordiori commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The backend now selects the organization and cluster with headers and takes organization IDs in paths. The CLI still built name-based query params and paths.

  • Resolve names to IDs in the client and send X-RawTree-Organization-Id and X-RawTree-Cluster-Id.
  • Resolve the organization and cluster once from flags, environment and config, and hand commands a client scoped to them instead of building organization=/cluster= query params.
  • Use organization IDs in paths.
  • API keys resolve names against their own organization and cluster, and workflow commands no longer require selectors for them.
  • Save organization and cluster IDs next to the saved names. Selections from the config use the saved IDs, so requests skip the lookups and survive renames; flags and environment variables are still resolved by name.
  • When a request that used saved IDs is refused, check whether the credential can still see them and, if not, say how to refresh them.

Note

High Risk
This rewrites the HTTP client's routing, discovery, and credential handling for every command; regressions could mis-route requests, break API keys, or leave saved defaults out of sync with the server.

Overview
The CLI stops putting organization and cluster in URLs and instead carries them on ApiClient scope, resolved to X-RawTree-Organization-Id and X-RawTree-Cluster-Id (and regional routing when needed). Selector treats UUIDs as IDs and everything else as names; user sessions discover routes as before, while API keys resolve names only against their bound org/cluster.

Config now stores default_organization_id / default_cluster_id next to the saved names (auth, use, create flows), so routine calls can skip lookups and stay valid across renames. Commands were trimmed to plain paths like /v1/databases and org::database_path only adds database=—the shared scope helpers were removed.

Supporting changes include a thread-safe, Arc-shared routing cache, cluster discovery keyed by organization ID, organization admin routes using IDs in paths, a typed ServerError, and broad test updates for header-based scope.

Reviewed by Cursor Bugbot for commit 7a42606. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread src/client.rs Resolved
Comment thread src/commands/insert.rs Resolved
Resolve organization and cluster names to IDs in the client and send them
as X-RawTree-Organization-Id and X-RawTree-Cluster-Id instead of query
params. Commands pass a typed Scope, organization paths use IDs, and the
saved defaults also store IDs so requests skip the name lookups.

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread src/org.rs Resolved
Comment thread src/client/routing.rs Resolved

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread src/client.rs Resolved
Replace the saved-ID side table with a Selector type: main resolves the
organization and cluster from flags, environment and config, substituting
saved IDs for config selections, and hands commands a scoped client. The
client no longer knows where an ID came from.
The hint was added to any 403 or 404 after a command used saved IDs, so a
missing table or a non-admin API key was reported as a stale ID. Server
errors now carry their status, and on a refusal the CLI checks whether the
credential can still see the saved organization and cluster before adding
the hint.
@jordiori
jordiori requested a review from rmorehig November 26, 2026 10:48

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 875a308. Configure here.

Comment thread src/main.rs Resolved
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.

1 participant