Dashboard › cli › Distillation
0409e659-e743-4d32-ae4c-4761f043157a["lore_tm_v1_YTiZKCpCOAbd2gg-eAaVx3DqUbSFPoEqCfWHU1W2diM","lore_tm_v1_OJhFXLX_vAhei-SdC4ZSSVy-cRmyJoaEMlhyerYCl0k"]
packages/cli/src/lib/region.ts defines process-local regionCache as new Map<string, Promise<string>>(), keyed by orgSlug; it deduplicates concurrent region lookups and retains resolved promises as a warm in-memory cache.resolveOrgRegion(orgSlug) first returns any existing promise from regionCache; otherwise it calls resolveOrgRegionUncached(orgSlug), caches that promise, and attaches promise.catch(() => regionCache.delete(orgSlug)) so rejected AuthError lookups can be retried after re-authentication.resolveOrgRegionUncached(orgSlug) resolution order is: 1. return getOrgRegion(orgSlug) when cached in SQLite; 2. derive baseUrl with getSentryBaseUrl() and SDK configuration with getSdkConfig(baseUrl); 3. call getOrganization({ ...config, path: { organization_id_or_slug: orgSlug } }) inside withAuthGuard(); 4. throw response.error when defined so auth errors propagate; 5. use response.data?.links?.regionUrl || baseUrl; 6. persist it through setOrgRegion(orgSlug, regionUrl); 7. return result.value when result.ok, otherwise fall back to baseUrl.api-client to avoid a circular dependency. setOrgRegion() also extends the in-process trust class so the next request to the resolved region passes the fetch-layer guard without separate registration.withAuthGuard(); AuthError propagates and causes promise-cache eviction, while network errors, 404s, and other non-auth failures resolve to the default baseUrl, supporting self-hosted instances without multi-region.isMultiRegionEnabled() reads getConfiguredSentryUrl() and returns false when a configured URL exists and !isSentrySaasUrl(baseUrl); otherwise it returns true.resolveOrgFromCache(orgSlug) first checks whether getOrgRegion(orgSlug) exists and returns the original slug on a direct hit. On a miss, it computes stripDsnOrgPrefix(orgSlug); when that differs from the input, it calls getOrgByNumericId(numericId) and returns match.slug when found, otherwise undefined.acme-corp from DSN numeric identifiers such as o1081365. Normal-slug strategy: 1. check local cache, 2. call resolveOrgRegion(orgSlug) once to validate the slug and populate region data, 3. fall back to the original slug for downstream error handling. DSN-ID strategy: 1. check local numeric-ID-to-slug cache, 2. refresh the full organization list through an API fan-out to all regions, 3. retry the cache and fall back to the original identifier.org="..": raw URL https://us.sentry.io/api/0/organizations/../agents/conversations/conv/?per_page=1000 normalized to request URL https://us.sentry.io/api/0/agents/conversations/conv/?per_page=1000.org="acme?x=y": both raw and request URL were https://us.sentry.io/api/0/organizations/acme?x=y/agents/conversations/conv/?per_page=1000, causing ?x=y/agents/conversations/conv/?per_page=1000 to be interpreted as the query portion rather than a path segment.org="acme#frag": both raw and request URL were https://us.sentry.io/api/0/organizations/acme#frag/agents/conversations/conv/?per_page=1000, causing #frag/agents/conversations/conv/?per_page=1000 to be interpreted as the fragment portion rather than a path segment.