Skip to content

Commit 78cfaf1

Browse files
Brooooooklynclaude
andcommitted
fix(cli): bound --status exact codes to the 100-599 HTTP range
Review feedback: the `\d{3}` alternative accepted out-of-range values such as `600`, `000`, or `999`, so a typo was passed through to the API and silently produced an empty result instead of the documented invalid-status error. Mirrors the same bound applied server-side. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011iZtc3xSUBc3NqapBXuYCH
1 parent 8661aad commit 78cfaf1

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/void/src/cli/project-args.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { SubcommandDef } from './subcommand-prompt.ts';
22

33
const LOG_LEVELS = new Set(['error', 'warn', 'info', 'log', 'debug', 'all']);
4-
// A status class (`5xx`), an exact 3-digit code (`500`), or `all`.
5-
const STATUS_FILTER = /^([1-5]xx|\d{3}|all)$/;
4+
// A status class (`5xx`), an exact code in the 100-599 HTTP range (`500`), or
5+
// `all`. Exact codes are range-bounded so a typo like `600` errors instead of
6+
// silently returning an empty result.
7+
const STATUS_FILTER = /^([1-5]xx|[1-5]\d{2}|all)$/;
68

79
export const projectSubcommands: Array<SubcommandDef> = [
810
{ name: 'status', arg: '[name]', description: 'Show deployments (omit name for linked project)' },

‎packages/void/test/unit/project-args.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ describe('parseProjectArgs', () => {
113113
);
114114
});
115115

116+
it('rejects exact codes outside the 100-599 HTTP range', () => {
117+
for (const v of ['000', '099', '600', '999']) {
118+
expect(() => parseProjectArgs(['requests', '--status', v])).toThrow(
119+
`project: Invalid --status '${v}'. Use a class like 5xx or an exact code like 500.`,
120+
);
121+
}
122+
});
123+
116124
it('rejects unknown flags', () => {
117125
expect(() => parseProjectArgs(['requests', '--bogus'])).toThrow(
118126
"project: Unexpected argument '--bogus'.",

0 commit comments

Comments
 (0)