lakebox: resolve names → IDs from local cache#5371
Merged
akshaysingla-db merged 2 commits intoMay 29, 2026
Merged
Conversation
Contributor
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
`databricks lakebox ssh my-project` and the same shape on status /
stop / start / delete / config / default now accept a `--name` value
in place of a sandbox ID, resolved purely from local state — no
extra API call on the slow path.
How it works:
- The state file (~/.databricks/lakebox.json) grows a per-profile
`sandboxes` list of (id, name) pairs.
- `resolveLocalID` maps the user-typed arg to an ID:
1. Exact ID match → return as-is (fast path; preserves the
existing "I know the ID" workflow).
2. Exact name match in cache → return the corresponding ID.
Ambiguous names (server allows duplicate --name values)
error out with the candidate IDs.
3. No match → pass arg through unchanged. Either it's an ID the
cache hasn't seen yet (fresh sandbox, user hasn't `list`ed)
or a typo; either way the next API call surfaces a clean 404.
The cache is populated incrementally by the commands that already
observe sandbox state:
- `create` upserts the new sandbox.
- `list` replaces the cache in full.
- `status` / `stop` / `start` / `config` / `default` upsert the
one entry they touch.
- `delete` removes it.
A stale cache can only fail to find a name; it can never cause the
CLI to operate on the wrong sandbox. Resolution is ID-first so a
sandbox whose `--name` happens to collide with another sandbox's ID
never gets mistakenly matched by name.
Co-authored-by: Isaac
Now that the resolver populates `~/.databricks/lakebox.json` with an (id, name) cache per profile, the completion path no longer needs to hit the API on every `<TAB>`. Reads the cache directly via `getSandboxes`, falling back to no suggestions when the cache is empty. Benefits: - Instant tab feedback. No round-trip blocks the shell. - Tab works offline / on a flaky network. - Auth token issues no longer make completion fail silently. Trade-off: a sandbox created from another machine doesn't show up until you run `lakebox list` locally. That's the same refresh model as the resolver itself, so the two stay consistent: if `lakebox ssh my-project` can resolve it, `lakebox ssh <TAB>` can suggest it. Also offers display names as suggestions when they differ from the ID, so users who set `--name foo` can tab to either `foo` or the underlying pet-name. `ssh-key delete <hash>` still calls the API — key hashes aren't cached locally (per-user cap is ~100 and listing is cheap). Co-authored-by: Isaac
31f0d93 to
8e5e950
Compare
60997ef
into
databricks:demo-lakebox
12 of 19 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
databricks lakebox ssh my-projectand the same shape on status / stop / start / delete / config / default now accept a--namevalue in place of a sandbox ID, resolved purely from local state — no extra API call on the slow path.How it works:
sandboxeslist of (id, name) pairs.resolveLocalIDmaps the user-typed arg to an ID:listed) or a typo; either way the next API call surfaces a clean 404.The cache is populated incrementally by the commands that already observe sandbox state:
createupserts the new sandbox.listreplaces the cache in full.status/stop/start/config/defaultupsert the one entry they touch.deleteremoves it.A stale cache can only fail to find a name; it can never cause the CLI to operate on the wrong sandbox. Resolution is ID-first so a sandbox whose
--namehappens to collide with another sandbox's ID never gets mistakenly matched by name.Co-authored-by: Isaac
Changes
Why
Tests