ai-gateway validate rule: `\d+-\d+[)'"]` regex matches ISO dates as false positive
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 287
- Forks
- 58
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 17
Description
Summary
The posttooluse-validate hook's ai-gateway skill includes a validation rule intended to catch model slugs that use hyphens for version numbers (e.g., claude-sonnet-4-6 instead of claude-sonnet-4.6). The rule's regex \d+-\d+[)'"] is too broad and produces false positives on ISO 8601 date literals like 2026-05-16) in unrelated documents.
Reproduction
-
Use Edit/Write on any
.mdfile under a project where theai-gatewayskill is matched (e.g., a doc that mentions Supabase + Vercel AI SDK in nearby content). -
Include any text containing an ISO date followed by a closing paren, single quote, or double quote. Example:
| 문서 버전 | v2 (2026-05-16) — 마크다운 정본 + 도구 어댑터 framing | -
Hook blocks with:
VALIDATION (1 error): - Line N [ERROR]: Model slug uses hyphens — use dots not hyphens for version numbers (e.g., claude-sonnet-4.6)
The 05-16) substring in 2026-05-16) matches \d+-\d+[)'"] and triggers the rule even though the line has nothing to do with a model identifier.
Expected
The rule should fire only on actual model slug contexts (e.g., claude-sonnet-4-6), gpt-4-1), or strings near model: or provider prefixes like anthropic/, openai/, google/).
Actual
Any MM-DD), MM-DD', or MM-DD" pattern fires the rule. This affects any markdown/docs that include dates such as authoring dates, changelogs, or YAML frontmatter dates rendered into text.
Root Cause
skills/ai-gateway/SKILL.md — the validate rule entry:
- pattern: \d+-\d+[)'"]
message: 'Model slug uses hyphens — use dots not hyphens for version numbers (e.g., claude-sonnet-4.6)'
severity: error
The pattern has no boundary anchoring or context requirement, so it matches numeric-hyphen-numeric substrings wherever they appear.
Suggested Fixes (any of)
-
Anchor to model slug context — require a known model family prefix:
pattern: (?:claude|gpt|gemini|llama|mistral|sonnet|opus|haiku|flash|pro)-?\d+-\d+[)'"] -
Negative lookbehind for digits — prevent matching the inside of larger numeric sequences (e.g., dates have 4-digit year preceding):
pattern: (?<![\d-])\d+-\d+[)'"]This won't fix
05-16)after2026-because of the hyphen, but combining with a length check on the left number would: model versions are typically\d{1,2}-\d{1,2}, dates have\d{4}-\d{2}-\d{2}. -
skipIfMatchContainsfor date-like context — add a guard:pattern: \d+-\d+[)'"] skipIfFileContains: \d{4}-\d{2}-\d{2}This is coarse — better is per-match guard, but the skill rule schema may not support it yet.
-
Tighten to model assignment context — only fire inside string literals adjacent to
model:or provider slashes:pattern: ['"][\w-]+/[\w-]*\d+-\d+[)'"]This narrows to actual provider/model slug strings such as
'anthropic/claude-sonnet-4-6'.
Environment
- vercel-plugin version: 0.22.0
- Cache path:
~/.claude/plugins/cache/claude-plugins-official/vercel/0b375ac333f1 - Triggered hook event:
PostToolUse:Edit - Matched skills (from hook output):
ai-elements,ai-gateway,ai-generation-persistence,ai-sdk - File that triggered: a Korean-language webfortd KB architecture doc containing the date
2026-05-16)in a metadata table row
Impact
Low severity but blocks Edit/Write until the false-positive line is reformatted. Korean date convention frequently uses ISO format with hyphens, so any documentation/changelog work in repos that match the ai-gateway skill paths hits this. Workaround on user side: use slashes or Korean text format for dates (2026/05/16 or 2026년 5월 16일), but that is an unrelated cost to a documentation author.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the validate rule in skills/ai-gateway/SKILL.md and reproduce the false positive using an ISO date such as 2026-05-16). Check the rule against both date literals and model slugs such as claude-sonnet-4-6; done means dates no longer trigger while the intended model-version warning still does.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- yaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100