Skip to content

Commit 47e63fd

Browse files
committed
fix(profile): fix invalid --org flag in error suggestion
When project is null, the stale/unknown ref error messages suggested 'sentry profile list --org <org>' but profile list has no --org flag. Now omits the target when project is unknown, letting auto-detection handle it.
1 parent 9a362cc commit 47e63fd

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

src/lib/resolve-transaction.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,32 @@ function buildStaleAliasError(
113113

114114
const isNumeric = NUMERIC_PATTERN.test(ref);
115115
const refType = isNumeric ? "index" : "alias";
116-
const listCmd = current.project
117-
? `sentry profile list ${current.org}/${current.project} --period ${current.period}`
118-
: `sentry profile list --org ${current.org} --period ${current.period}`;
116+
const listCmd = buildListCommand(
117+
current.org,
118+
current.project,
119+
current.period
120+
);
119121

120122
return new ConfigError(
121123
`Transaction ${refType} '${ref}' is from a ${reason}.`,
122124
`Run '${listCmd}' to refresh aliases.`
123125
);
124126
}
125127

128+
/**
129+
* Build a suggested `sentry profile list` command string.
130+
* Uses positional `<org>/<project>` when a project is known, otherwise
131+
* omits the target to let auto-detection handle it.
132+
*/
133+
function buildListCommand(
134+
org: string,
135+
project: string | null,
136+
period: string
137+
): string {
138+
const target = project ? ` ${org}/${project}` : "";
139+
return `sentry profile list${target} --period ${period}`;
140+
}
141+
126142
/**
127143
* Build error for unknown alias/index.
128144
*/
@@ -132,9 +148,11 @@ function buildUnknownRefError(
132148
): ConfigError {
133149
const isNumeric = NUMERIC_PATTERN.test(ref);
134150
const refType = isNumeric ? "index" : "alias";
135-
const listCmd = options.project
136-
? `sentry profile list ${options.org}/${options.project} --period ${options.period}`
137-
: `sentry profile list --org ${options.org} --period ${options.period}`;
151+
const listCmd = buildListCommand(
152+
options.org,
153+
options.project,
154+
options.period
155+
);
138156

139157
return new ConfigError(
140158
`Unknown transaction ${refType} '${ref}'.`,

0 commit comments

Comments
 (0)