fix(codex-quota): guard feature label type in quota windows (#1346)

This commit is contained in:
Kai (Tam Nhu) Tran authored and GitHub committed 2026-05-23 16:55:55 -04:00
1 parent 66966f3527
commit b71fe5dd6e
4 files changed
+32 -3

No files matched your search

+2 -2
View File
@@ -384,8 +384,8 @@ function getCodexWindowKindFromLabel(label: string): CodexWindowKind {
* "OmniReview" -> "OmniReview"
* "" -> ""
*/
export function prettifyCodexFeatureLabel(featureLabel: string): string {
const trimmed = (featureLabel || '').trim();
export function prettifyCodexFeatureLabel(featureLabel: unknown): string {
const trimmed = typeof featureLabel === 'string' ? featureLabel.trim() : '';
if (!trimmed) return '';
const stripped = trimmed.replace(/^GPT-[\d.]+-Codex-/i, '');
if (stripped !== trimmed && stripped.length > 0) {
@@ -37,6 +37,11 @@ describe('prettifyCodexFeatureLabel', () => {
expect(prettifyCodexFeatureLabel(' ')).toBe('');
expect(prettifyCodexFeatureLabel(' GPT-5.3-Codex-Spark ')).toBe('Codex Spark');
});
it('returns empty string for non-string input', () => {
expect(prettifyCodexFeatureLabel({ label: 'Spark' })).toBe('');
expect(prettifyCodexFeatureLabel(123)).toBe('');
});
});
describe('getCodexWindowKind', () => {