Skip to content

Commit 928a4ba

Browse files
committed
fix: move log.warn to command func, use upfront getSystemErrorMap check
- Move the api/0/ prefix warning from normalizeEndpoint (pure function) to the command's func() to avoid polluting stderr during unit tests - Remove api/0? query-string edge case per reviewer feedback - Replace try-catch SDK patch with upfront hasGetSystemErrorMap check at module load — excludes NodeSystemError when method is missing
1 parent cbd4e2a commit 928a4ba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/commands/api.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ export function normalizeEndpoint(endpoint: string): string {
9494
// like /api/0/api/0/... (see CLI-K1).
9595
// Also strip bare "api/0" to maintain idempotency.
9696
if (trimmed.startsWith("api/0/") || trimmed === "api/0") {
97-
log.warn(
98-
"Endpoint includes the /api/0/ prefix which is added automatically — stripping it to avoid a doubled path"
99-
);
10097
trimmed = trimmed.slice(trimmed.startsWith("api/0/") ? 6 : 5);
10198
}
10299

@@ -1171,6 +1168,14 @@ export const apiCommand = buildCommand({
11711168
const { stdin } = this;
11721169

11731170
const normalizedEndpoint = normalizeEndpoint(endpoint);
1171+
1172+
// Warn if the user included the /api/0/ prefix (CLI-K1)
1173+
const bare = endpoint.startsWith("/") ? endpoint.slice(1) : endpoint;
1174+
if (bare.startsWith("api/0/") || bare === "api/0") {
1175+
log.warn(
1176+
"Endpoint includes the /api/0/ prefix which is added automatically — stripping it to avoid a doubled path"
1177+
);
1178+
}
11741179
const { body, params } = await resolveBody(flags, stdin);
11751180

11761181
const headers =

0 commit comments

Comments
 (0)