vercel / vercel/vercel-plugin

ai-gateway validate rule: `\d+-\d+[)'"]` regex matches ISO dates as false positive

Open Beginner friendly
#85 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Use Edit/Write on any .md file under a project where the ai-gateway skill is matched (e.g., a doc that mentions Supabase + Vercel AI SDK in nearby content).

  2. Include any text containing an ISO date followed by a closing paren, single quote, or double quote. Example:

    | 문서 버전 | v2 (2026-05-16) — 마크다운 정본 + 도구 어댑터 framing |
    
  3. 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)

  1. Anchor to model slug context — require a known model family prefix:

    pattern: (?:claude|gpt|gemini|llama|mistral|sonnet|opus|haiku|flash|pro)-?\d+-\d+[)'"]
    
  2. 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) after 2026- 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}.

  3. skipIfMatchContains for 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.

  4. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.