Repository navigation
feat(cli): Warm attribute keys for completion on login and setup - #1788
Merged
Merged
Conversation
Field completion reads attribute keys that only `sentry attribute list` fetched until now. `auth login` and `cli setup` (which `cli upgrade` runs) now request the spans, logs, and tracemetrics keys of the default org plus up to three orgs used in the last week, in parallel, and abort after one second. Setup skips datasets fetched in the last day, and with `--no-completions` or without a stored login. The attribute seed stores Sentry-defined keys first, so stored keys sorted by name no longer push `span.*` and other conventions out of the 500-entry cache in large orgs. Refs #1787 Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
BYK
approved these changes
Nov 1, 2026
BYK
enabled auto-merge (squash)
November 1, 2026 19:10
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c51cf30. Configure here.
BYK
pushed a commit
that referenced
this pull request
Nov 1, 2026
Follow-up to #1788, addressing [Warden's finding](#1788 (comment)) that landed after the merge. On a fresh curl install, `cli setup` warms attribute keys before its optional auto-login stores a token. That warm-up exits early because no one is logged in yet. `runInteractiveLogin()` then succeeds without warming anything, so field completion stays empty on the main first-install path. The org/region cache is also empty at that point, so `pickWarmupOrgs()` would find nothing to warm anyway. The fix: - Moves `warmCachesAfterLogin()` (list orgs with a 1s cap, then warm attribute keys) from `auth/login.ts` into `lib/completion-warmup.ts`. - Calls it from setup after a successful auto-login, unless `--no-completions` is set. `auth login` behaves the same as before. - Moves the org-list stall/failure tests to `test/lib/completion-warmup.test.ts`, next to a success-path test. Adds setup tests for the auto-login warm-up with completions on and off. Verified with `oxlint`, `oxfmt --check`, `tsc --noEmit`, and the `completion-warmup`, `commands/cli`, and `commands/auth` suites (434 passed, 3 skipped). <!-- junior-session-footer:start --> <!-- junior-conversation-id:local%3Aweb%3A6e7d266c60c8764ce956d19f --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A6e7d266c60c8764ce956d19f/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
This branch was previously deployed
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.

Closes #1787.
Field completion (
explore --field,dashboard widget --query,alert metrics --aggregate, …) reads attribute keys that, until now, onlysentry attribute listfetched. So on a fresh login or install it offered nothing.Warm-up (
src/lib/completion-warmup.ts).auth loginandcli setup(whichcli upgraderuns) now request thespans,logsandtracemetricskeys in parallel, one request per dataset, and abort them all after 1 second so the command never looks stuck. The fetch layer stores the keys as it already does for every response. The warm-up never throws or prompts, and logs failures (404 without the feature, 403, 5xx, offline, timeout) only at debug level.project_cacheandcompletion_cache, not counting the warmed attribute kinds themselves). With no default and no history, it warms the only org if the account has exactly one. Only orgs whose region the active account already has cached qualify, so the warm-up never switches accounts or makes a region lookup it can't abort.Sentry-defined keys first. The endpoint lists the keys an org stores by internal name, one attribute type after another, and appends a few curated aliases and contexts. In a large org, numeric and vendor keys filled the 500-entry cache before
span.*. The attribute seed now storesattributeSource.source_type == "sentry"keys first. That covers stored keys that map to a Sentry definition, which the server tagssentrytoo (translate_internal_to_public_alias). This also helpsattribute list.listTraceItemAttributestakes an optionalsignal, which the transport already honors during retries.Open question: in
cli setup, the warm-up can be the first API request in the process. So users withNODE_EXTRA_CA_CERTSpointed at SaaS, or with bothSENTRY_AUTH_TOKENand a stored login, now see that one-time advisory notice during upgrades. They already see it on every other networked command. I left it as is rather than adding hooks to suppress those notices. Happy to add them if we want setup to stay fully silent.Server-side alternative (not used here):
GET /organizations/{org}/attribute-mappings/?type=spans&type=logs&type=tracemetricsalready returns the static Sentry-defined set without a Snuba query (src/sentry/api/endpoints/organization_attribute_mappings.py). It'sEXPERIMENTAL, though. It also includes secondary and deprecated aliases, leaves out virtual contexts, skips the expose checks, and reports units likemillisecondassearchType. So the warm-up keeps using the trace-items endpoint, which also returns the org's own keys. Adding asourceTypefilter to trace-items would mostly duplicate it, so no getsentry/sentry issue was filed.via @BYK.
--
View Session in Sentry