Skip to content

Commit 785c3f0

Browse files
committed
fix: address BugBot and Seer review feedback
- Make --period flag optional (no default) to fix sentinel-value bug where explicit --period 90d was silently overridden to 14d in trace mode. Now undefined = not set, project mode defaults to 90d, trace mode defaults to 14d. - Add json option to withProgress to suppress spinner in JSON mode, matching poll() behavior. Pass json: flags.json at all 19 call sites.
1 parent 2f3728b commit 785c3f0

File tree

13 files changed

+107
-83
lines changed

13 files changed

+107
-83
lines changed

AGENTS.md

Lines changed: 40 additions & 21 deletions
Large diffs are not rendered by default.

src/commands/dashboard/list.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ export const listCommand = buildCommand({
135135
}
136136

137137
const dashboards = await withProgress(
138-
{ message: `Fetching dashboards (up to ${flags.limit})...` },
138+
{
139+
message: `Fetching dashboards (up to ${flags.limit})...`,
140+
json: flags.json,
141+
},
139142
() => listDashboards(orgSlug, { perPage: flags.limit })
140143
);
141144
const url = buildDashboardsListUrl(orgSlug);

src/commands/issue/list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ async function handleOrgAllIssues(
812812
setContext([org], []);
813813

814814
const { issues, nextCursor } = await withProgress(
815-
{ message: `Fetching issues (up to ${flags.limit})...` },
815+
{ message: `Fetching issues (up to ${flags.limit})...`, json: flags.json },
816816
(setMessage) =>
817817
fetchOrgAllIssues(org, flags, cursor, (fetched, limit) =>
818818
setMessage(
@@ -954,7 +954,7 @@ async function handleResolvedTargets(
954954
: "Fetching issues";
955955

956956
const { results, hasMore } = await withProgress(
957-
{ message: `${baseMessage} (up to ${flags.limit})...` },
957+
{ message: `${baseMessage} (up to ${flags.limit})...`, json: flags.json },
958958
(setMessage) =>
959959
fetchWithBudget(
960960
activeTargets,

src/commands/log/list.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type ListFlags = {
4949
readonly limit: number;
5050
readonly query?: string;
5151
readonly follow?: number;
52-
readonly period: string;
52+
readonly period?: string;
5353
readonly json: boolean;
5454
readonly fresh: boolean;
5555
readonly fields?: string[];
@@ -198,15 +198,19 @@ function parseLogListArgs(args: string[]): ParsedLogArgs {
198198
* Returns the logs and a hint. The caller yields the result and
199199
* returns the hint as a footer via `CommandReturn`.
200200
*/
201+
/** Default time period for project-scoped log queries */
202+
const DEFAULT_PROJECT_PERIOD = "90d";
203+
201204
async function executeSingleFetch(
202205
org: string,
203206
project: string,
204207
flags: ListFlags
205208
): Promise<FetchResult> {
209+
const period = flags.period ?? DEFAULT_PROJECT_PERIOD;
206210
const logs = await listLogs(org, project, {
207211
query: flags.query,
208212
limit: flags.limit,
209-
statsPeriod: flags.period,
213+
statsPeriod: period,
210214
});
211215

212216
if (logs.length === 0) {
@@ -459,9 +463,9 @@ async function executeTraceSingleFetch(
459463
traceId: string,
460464
flags: ListFlags
461465
): Promise<FetchResult> {
462-
// In trace mode, use a shorter default period if the user hasn't
463-
// explicitly changed it from the command-level default of "90d".
464-
const period = flags.period === "90d" ? DEFAULT_TRACE_PERIOD : flags.period;
466+
// Use the explicit period if set, otherwise default to 14d for trace mode.
467+
// The flag is optional (no default) so undefined means "not explicitly set".
468+
const period = flags.period ?? DEFAULT_TRACE_PERIOD;
465469

466470
const logs = await listTraceLogs(org, traceId, {
467471
query: flags.query,
@@ -663,8 +667,9 @@ export const listCommand = buildListCommand("log", {
663667
period: {
664668
kind: "parsed",
665669
parse: String,
666-
brief: 'Time period (e.g., "90d", "14d", "24h")',
667-
default: "90d",
670+
brief:
671+
'Time period (e.g., "90d", "14d", "24h"). Default: 90d (project mode), 14d (trace mode)',
672+
optional: true,
668673
},
669674
fresh: FRESH_FLAG,
670675
},
@@ -740,7 +745,7 @@ export const listCommand = buildListCommand("log", {
740745
}
741746

742747
const { result, hint } = await withProgress(
743-
{ message: "Fetching logs..." },
748+
{ message: "Fetching logs...", json: flags.json },
744749
() => executeTraceSingleFetch(org, traceId, flags)
745750
);
746751
yield new CommandOutput(result);
@@ -781,7 +786,7 @@ export const listCommand = buildListCommand("log", {
781786
}
782787

783788
const { result, hint } = await withProgress(
784-
{ message: "Fetching logs..." },
789+
{ message: "Fetching logs...", json: flags.json },
785790
() => executeSingleFetch(org, project, flags)
786791
);
787792
yield new CommandOutput(result);

src/commands/org/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const listCommand = buildCommand({
132132
applyFreshFlag(flags);
133133

134134
const orgs = await withProgress(
135-
{ message: "Fetching organizations..." },
135+
{ message: "Fetching organizations...", json: flags.json },
136136
() => listOrganizationsUncached()
137137
);
138138
const limitedOrgs = orgs.slice(0, flags.limit);

src/commands/project/list.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export async function handleAutoDetect(
335335
} = await resolveOrgsForAutoDetect(cwd);
336336

337337
const { projects: allProjects, nextCursor } = await withProgress(
338-
{ message: "Fetching projects..." },
338+
{ message: "Fetching projects...", json: flags.json },
339339
() => fetchAutoDetectProjects(orgsToFetch, flags)
340340
);
341341

@@ -392,7 +392,7 @@ export async function handleExplicit(
392392
flags: ListFlags
393393
): Promise<ListResult<ProjectWithOrg>> {
394394
const projectResult = await withProgress(
395-
{ message: "Fetching projects..." },
395+
{ message: "Fetching projects...", json: flags.json },
396396
() => withAuthGuard(() => getProject(org, projectSlug))
397397
);
398398
if (!projectResult.ok) {
@@ -442,7 +442,7 @@ export async function handleOrgAll(
442442
): Promise<ListResult<ProjectWithOrg>> {
443443
const { org, flags, contextKey, cursor } = options;
444444
const response: PaginatedResponse<SentryProject[]> = await withProgress(
445-
{ message: "Fetching projects..." },
445+
{ message: "Fetching projects...", json: flags.json },
446446
() =>
447447
listProjectsPaginated(org, {
448448
cursor,
@@ -506,7 +506,7 @@ export async function handleProjectSearch(
506506
flags: ListFlags
507507
): Promise<ListResult<ProjectWithOrg>> {
508508
const { projects } = await withProgress(
509-
{ message: "Fetching projects..." },
509+
{ message: "Fetching projects...", json: flags.json },
510510
() => findProjectsBySlug(projectSlug)
511511
);
512512
const filtered = filterByPlatform(projects, flags.platform);

src/commands/span/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export const listCommand = buildCommand({
262262

263263
// Fetch spans from EAP endpoint
264264
const { data: spanItems, nextCursor } = await withProgress(
265-
{ message: "Fetching spans..." },
265+
{ message: "Fetching spans...", json: flags.json },
266266
() =>
267267
listSpans(org, project, {
268268
query: apiQuery,

src/commands/trace/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export const listCommand = buildListCommand("trace", {
247247
const cursor = resolveOrgCursor(flags.cursor, PAGINATION_KEY, contextKey);
248248

249249
const { data: traces, nextCursor } = await withProgress(
250-
{ message: "Fetching traces..." },
250+
{ message: "Fetching traces...", json: flags.json },
251251
() =>
252252
listTransactions(org, project, {
253253
query: flags.query,

src/commands/trace/logs.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ export const logsCommand = buildCommand({
174174
return;
175175
}
176176

177-
const logs = await withProgress({ message: "Fetching trace logs..." }, () =>
178-
listTraceLogs(org, traceId, {
179-
statsPeriod: flags.period,
180-
limit: flags.limit,
181-
query: flags.query,
182-
})
177+
const logs = await withProgress(
178+
{ message: "Fetching trace logs...", json: flags.json },
179+
() =>
180+
listTraceLogs(org, traceId, {
181+
statsPeriod: flags.period,
182+
limit: flags.limit,
183+
query: flags.query,
184+
})
183185
);
184186

185187
// Reverse to chronological order (API returns newest-first)

src/commands/trial/list.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export const listCommand = buildCommand({
221221
],
222222
},
223223
},
224-
async *func(this: SentryContext, _flags: ListFlags, org?: string) {
224+
async *func(this: SentryContext, flags: ListFlags, org?: string) {
225225
const resolved = await resolveOrg({
226226
org,
227227
cwd: this.cwd,
@@ -231,8 +231,9 @@ export const listCommand = buildCommand({
231231
throw new ContextError("Organization", "sentry trial list <org>");
232232
}
233233

234-
const info = await withProgress({ message: "Fetching trials..." }, () =>
235-
getCustomerTrialInfo(resolved.org)
234+
const info = await withProgress(
235+
{ message: "Fetching trials...", json: flags.json },
236+
() => getCustomerTrialInfo(resolved.org)
236237
);
237238
const productTrials = info.productTrials ?? [];
238239

0 commit comments

Comments
 (0)