Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/commands/alert/issues/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ async function handleResolvedTargets(
);
const filteredRows = flags.query
? allRows.filter((row) =>
row.rule.name.toLowerCase().includes(flags.query?.toLowerCase() ?? "")
(row.rule.name ?? "")
.toLowerCase()
.includes(flags.query?.toLowerCase() ?? "")
)
: allRows;

Expand Down Expand Up @@ -471,7 +473,7 @@ function formatIssueAlertListHuman(result: IssueAlertListResult): string {

const tableRows: Row[] = rows.map(({ rule: r, target }) => ({
id: r.id,
name: escapeMarkdownCell(r.name),
name: escapeMarkdownCell(r.name ?? "(untitled)"),
...(isMultiProject && {
project: `${target.org}/${target.project}`,
}),
Expand Down
6 changes: 4 additions & 2 deletions src/commands/alert/issues/rule-resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ export async function resolveIssueAlertRule(
for (const target of targets) {
const rules = await listAllIssueRulesForTarget(target);
for (const r of rules) {
allRuleNames.push(r.name);
if (r.name) {
allRuleNames.push(r.name);
}
}
const exact = rules.find(
(rule) => rule.name.toLowerCase() === ref.toLowerCase()
(rule) => rule.name && rule.name.toLowerCase() === ref.toLowerCase()
);
if (exact) {
hits.push({ target, rule: exact });
Expand Down
6 changes: 4 additions & 2 deletions src/commands/alert/metrics/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ async function handleResolvedOrgs(
);
const filteredRows = flags.query
? allRows.filter((row) =>
row.rule.name.toLowerCase().includes(flags.query?.toLowerCase() ?? "")
(row.rule.name ?? "")
.toLowerCase()
.includes(flags.query?.toLowerCase() ?? "")
)
: allRows;

Expand Down Expand Up @@ -470,7 +472,7 @@ function formatMetricAlertListHuman(result: MetricAlertListResult): string {

const tableRows: Row[] = rows.map(({ rule: r, orgSlug }) => ({
id: r.id,
name: escapeMarkdownCell(r.name),
name: escapeMarkdownCell(r.name ?? "(untitled)"),
...(isMultiOrg && { org: orgSlug }),
aggregate: r.aggregate,
dataset: r.dataset,
Expand Down
6 changes: 4 additions & 2 deletions src/commands/alert/metrics/rule-resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ export async function resolveMetricAlertRule(
for (const orgSlug of orgSlugs) {
const rules = await listAllMetricRulesForOrg(orgSlug);
for (const r of rules) {
allNames.push(r.name);
if (r.name) {
allNames.push(r.name);
}
}
const exact = rules.find(
(rule) => rule.name.toLowerCase() === ref.toLowerCase()
(rule) => rule.name && rule.name.toLowerCase() === ref.toLowerCase()
);
if (exact) {
hits.push({ orgSlug, rule: exact });
Expand Down
7 changes: 5 additions & 2 deletions src/commands/log/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import * as Sentry from "@sentry/node-core/light";
import type { SentryContext } from "../../context.js";
import {
API_MAX_PER_PAGE,
type LogSortDirection,
listLogs,
listTraceLogs,
Expand Down Expand Up @@ -196,7 +197,8 @@ async function executeSingleFetch(
};
}

const hasMore = logs.length >= flags.limit;
const effectivePerPage = Math.min(flags.limit, API_MAX_PER_PAGE);
const hasMore = logs.length >= effectivePerPage;
const countText = `Showing ${logs.length} log${logs.length === 1 ? "" : "s"}.`;
const tip = hasMore ? " Use --limit to show more, or -f to follow." : "";

Expand Down Expand Up @@ -501,7 +503,8 @@ async function executeTraceSingleFetch(
};
}

const hasMore = logs.length >= flags.limit;
const effectivePerPage = Math.min(flags.limit, API_MAX_PER_PAGE);
const hasMore = logs.length >= effectivePerPage;
const countText = `Showing ${logs.length} log${logs.length === 1 ? "" : "s"} for trace ${traceId}.`;
const tip = hasMore ? " Use --limit to show more." : "";

Expand Down
3 changes: 2 additions & 1 deletion src/commands/project/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import type { SentryContext } from "../../context.js";
import {
API_MAX_PER_PAGE,
findProjectsBySlug,
getProject,
listOrganizations,
Expand Down Expand Up @@ -451,7 +452,7 @@ export async function handleOrgAll(
() =>
listProjectsPaginated(org, {
cursor,
perPage: flags.limit,
perPage: Math.min(flags.limit, API_MAX_PER_PAGE),
})
);

Expand Down
4 changes: 2 additions & 2 deletions src/lib/api/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export async function listLogs(
field: fields,
project: isNumericProject ? [Number(projectSlug)] : undefined,
query: fullQuery || undefined,
per_page: options.limit || API_MAX_PER_PAGE,
per_page: Math.min(options.limit || API_MAX_PER_PAGE, API_MAX_PER_PAGE),
statsPeriod:
options.start || options.end
? undefined
Expand Down Expand Up @@ -343,7 +343,7 @@ export async function listTraceLogs(
: (options.statsPeriod ?? "14d"),
start: options.start,
end: options.end,
per_page: options.limit ?? API_MAX_PER_PAGE,
per_page: Math.min(options.limit ?? API_MAX_PER_PAGE, API_MAX_PER_PAGE),
query: options.query,
sort: toApiSort(options.sort),
},
Expand Down
3 changes: 2 additions & 1 deletion src/lib/org-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/

import {
API_MAX_PER_PAGE,
findProjectsBySlug,
listOrganizations,
type PaginatedResponse,
Expand Down Expand Up @@ -465,7 +466,7 @@ export async function handleOrgAll<TEntity, TWithOrg>(
() =>
config.listPaginated(org, {
cursor,
perPage: flags.limit,
perPage: Math.min(flags.limit, API_MAX_PER_PAGE),
})
);

Expand Down
Loading