Merge pull request #1433 from kaitranntt/codex/fix-issue-with-profile-query-handling

fix: validate usage profile query type
This commit is contained in:
Kai (Tam Nhu) Tran
2026-05-30 15:46:47 -04:00
committed by GitHub
2 changed files with 25 additions and 8 deletions
+7 -2
View File
@@ -9,8 +9,13 @@ export interface ProfileScopedUsageData {
const PROFILE_NAME_REGEX = /^[A-Za-z0-9._-]+$/;
export function normalizeProfileQuery(profile?: string): string | undefined {
const value = profile?.trim();
export function normalizeProfileQuery(profile?: unknown): string | undefined {
if (profile === undefined) return undefined;
if (typeof profile !== 'string') {
throw new Error('Invalid profile filter');
}
const value = profile.trim();
if (!value || value === 'all') return undefined;
if (!PROFILE_NAME_REGEX.test(value)) {
throw new Error('Invalid profile filter');