@@ -12,72 +12,33 @@ import {
1212 getLatestEvent ,
1313 isShortId ,
1414} from "../../lib/api-client.js" ;
15- import { getCachedProject , getDefaultOrganization } from "../../lib/config.js" ;
16- import { detectDsn } from "../../lib/dsn/index.js" ;
1715import {
1816 formatEventDetails ,
1917 formatIssueDetails ,
2018} from "../../lib/formatters/human.js" ;
2119import { writeJson } from "../../lib/formatters/json.js" ;
20+ import { resolveOrg } from "../../lib/resolve-target.js" ;
2221import type { SentryEvent , SentryIssue } from "../../types/index.js" ;
2322
2423type GetFlags = {
2524 readonly org ?: string ;
2625 readonly json : boolean ;
27- readonly event : boolean ;
2826} ;
2927
3028/**
31- * Try to fetch the latest event for an issue
29+ * Try to fetch the latest event for an issue.
30+ * Returns undefined if the fetch fails (non-blocking).
3231 */
3332async function tryGetLatestEvent (
3433 issueId : string
3534) : Promise < SentryEvent | undefined > {
3635 try {
3736 return await getLatestEvent ( issueId ) ;
3837 } catch {
39- // Event fetch might fail, continue without it
4038 return ;
4139 }
4240}
4341
44- /**
45- * Resolve organization from various sources for short ID lookup
46- */
47- async function resolveOrg (
48- flagOrg : string | undefined ,
49- cwd : string
50- ) : Promise < string | null > {
51- // 1. Check CLI flag
52- if ( flagOrg ) {
53- return flagOrg ;
54- }
55-
56- // 2. Check config defaults
57- const defaultOrg = await getDefaultOrganization ( ) ;
58- if ( defaultOrg ) {
59- return defaultOrg ;
60- }
61-
62- // 3. Try DSN auto-detection
63- try {
64- const dsn = await detectDsn ( cwd ) ;
65- if ( dsn ?. orgId ) {
66- // Check cache for org slug
67- const cached = await getCachedProject ( dsn . orgId , dsn . projectId ) ;
68- if ( cached ) {
69- return cached . orgSlug ;
70- }
71- // Fall back to numeric org ID (API accepts both)
72- return dsn . orgId ;
73- }
74- } catch {
75- // Detection failed
76- }
77-
78- return null ;
79- }
80-
8142/**
8243 * Write human-readable issue output
8344 */
@@ -100,7 +61,7 @@ export const getCommand = buildCommand({
10061 brief : "Get details of a specific issue" ,
10162 fullDescription :
10263 "Retrieve detailed information about a Sentry issue by its ID or short ID. " +
103- "Use -- event to also fetch the latest event details .\n\n" +
64+ "The latest event is automatically included for full context .\n\n" +
10465 "For short IDs (e.g., SPOTLIGHT-ELECTRON-4D), the organization is resolved from:\n" +
10566 " 1. --org flag\n" +
10667 " 2. Config defaults\n" +
@@ -129,11 +90,6 @@ export const getCommand = buildCommand({
12990 brief : "Output as JSON" ,
13091 default : false ,
13192 } ,
132- event : {
133- kind : "boolean" ,
134- brief : "Also fetch the latest event" ,
135- default : false ,
136- } ,
13793 } ,
13894 } ,
13995 async func (
@@ -149,22 +105,23 @@ export const getCommand = buildCommand({
149105 // Check if it's a short ID (contains letters) vs numeric ID
150106 if ( isShortId ( issueId ) ) {
151107 // Short ID requires organization context
152- const org = await resolveOrg ( flags . org , cwd ) ;
153- if ( ! org ) {
108+ const resolved = await resolveOrg ( { org : flags . org , cwd } ) ;
109+ if ( ! resolved ) {
154110 throw new Error (
155111 "Organization is required for short ID lookup.\n\n" +
156112 "Please specify it using:\n" +
157113 ` sentry issue get ${ issueId } --org <org-slug>\n\n` +
158114 "Or set SENTRY_DSN environment variable for automatic detection."
159115 ) ;
160116 }
161- issue = await getIssueByShortId ( org , issueId ) ;
117+ issue = await getIssueByShortId ( resolved . org , issueId ) ;
162118 } else {
163119 // Numeric ID can be fetched directly
164120 issue = await getIssue ( issueId ) ;
165121 }
166122
167- const event = flags . event ? await tryGetLatestEvent ( issue . id ) : undefined ;
123+ // Always fetch the latest event for full context
124+ const event = await tryGetLatestEvent ( issue . id ) ;
168125
169126 if ( flags . json ) {
170127 const output = event ? { issue, event } : { issue } ;
0 commit comments