Skip to content

fix: strip regex patterns invalid under strict provider validators - #68

Merged
Siumauricio merged 1 commit into
mainfrom
fix/strip-strict-invalid-regex-patterns
Aug 7, 2026
Merged

Siumauricio merged 1 commit into
mainfrom
fix/strip-strict-invalid-regex-patterns

Conversation

@Siumauricio

@Siumauricio Siumauricio commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #43.

Summary

Extends the runtime schema sanitization introduced in #58: in addition to lookarounds, any pattern that fails to compile under the strict RegExp v flag is now stripped from the tool schemas advertised via tools/list.

This fixes the database password pattern (^[a-zA-Z0-9@#%^&*()_+\-=[\]{}|;:,.<>?~]*$) — its unescaped [` inside the character class is valid classic ECMA-262 but rejected by DeepSeek and other strict provider validators, which broke all database tools (see #43).

Why this approach

  • Generic: catches any provider-incompatible pattern in any field, current or future — no hardcoded pattern strings or field-name allowlists.
  • Single sanitization layer: reuses the exact mechanism from fix: strip unsupported regex patterns from tool schemas #58 in server.ts, instead of adding a second strip pass in the codegen path.
  • Safe: server-side Zod validation is unchanged; only the JSON Schema exposed to clients loses the pattern.

Verification

  • All 15 tools affected by fix(schema): invalid regex in databasePassword patterns breaks DeepSeek API #43 (libsql-*, mariadb-*, mongo-*, mysql-*, postgres-*, redis-changePassword) verified clean in a real tools/list over InMemoryTransport.
  • Sweep across all 546 tools: the only 2 surviving patterns (^(all|\d+[smhd])$, ^[a-zA-Z0-9.\-_]+$) compile under strict syntax — nothing over-stripped.
  • New regression test walks every tool schema and fails if any pattern doesn't compile with the v flag.
  • pnpm test (6/6), pnpm type-check, pnpm build all pass.

Credit to @Baijack-star for the diagnosis in #43/#44 — this supersedes #44 with a generic runtime fix.

🤖 Generated with Claude Code

Extends the lookaround strip from #58: any schema pattern that fails to
compile under the RegExp v flag (e.g. the database password pattern with
an unescaped '[' inside a character class) is now removed from the
advertised tool schemas. DeepSeek and other strict validators reject
these patterns, breaking tools/list for all database tools.

Server-side Zod validation is unchanged; only the JSON Schema exposed to
clients is sanitized.

Fixes #43

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(schema): invalid regex in databasePassword patterns breaks DeepSeek API

1 participant