Skip to content

Commit d08dba6

Browse files
committed
fix(log-view): log numeric project ID resolution tip via consola
resolveTarget's project-search case now logs the 'Tip: Resolved project ID X to org/slug' message via consola info instead of relying on the stderr param that was removed from this command.
1 parent 2d5897b commit d08dba6

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/commands/log/view.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ type ViewFlags = {
3535
/** Usage hint for ContextError messages */
3636
const USAGE_HINT = "sentry log view <org>/<project> <log-id> [<log-id>...]";
3737

38+
/** Matches a string of all digits (numeric project ID) */
39+
const ALL_DIGITS_RE = /^\d+$/;
40+
3841
/**
3942
* Split a raw argument into individual log IDs.
4043
* Handles newline-separated IDs within a single argument (common when
@@ -124,21 +127,32 @@ export type ResolvedLogTarget = {
124127
* @returns Resolved target, or null if resolution produced nothing
125128
* @throws {ContextError} If org-all mode is used (requires specific project)
126129
*/
127-
function resolveTarget(
130+
async function resolveTarget(
128131
parsed: ReturnType<typeof parseOrgProjectArg>,
129132
logIds: string[],
130133
cwd: string
131-
): Promise<ResolvedLogTarget | null> | ResolvedLogTarget {
134+
): Promise<ResolvedLogTarget | null> {
132135
switch (parsed.type) {
133136
case "explicit":
134137
return { org: parsed.org, project: parsed.project };
135138

136-
case "project-search":
137-
return resolveProjectBySlug(
139+
case "project-search": {
140+
const result = await resolveProjectBySlug(
138141
parsed.projectSlug,
139142
USAGE_HINT,
140143
`sentry log view <org>/${parsed.projectSlug} ${logIds.join(" ")}`
141144
);
145+
if (
146+
ALL_DIGITS_RE.test(parsed.projectSlug) &&
147+
result.project !== parsed.projectSlug
148+
) {
149+
log.info(
150+
`Tip: Resolved project ID ${parsed.projectSlug} to ${result.org}/${result.project}. ` +
151+
"Use the slug form for faster lookups."
152+
);
153+
}
154+
return result;
155+
}
142156

143157
case "org-all":
144158
throw new ContextError("Specific project", USAGE_HINT);

0 commit comments

Comments
 (0)