Repository navigation
Conversation
Filter unknown-format warnings in the shared default Ajv factory. Cover every supported dialect, duplicate warnings, known formats, custom engines, and forwarding of other diagnostics. Adapted from sean-park-funda/typescript-sdk commit 36da288. Co-authored-by: sean-park-funda <sungjunpark7392@gmail.com>
🦋 Changeset detectedLatest commit: 0210f84 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
chrikrah
left a comment
There was a problem hiding this comment.
@senorMk, the spam is real, and most of it lands where nobody can fix it: client.ts:1846 compiles every third-party tool's outputSchema through the default engine, so a client author sees the vendor's google-duration and can't change it. non-blocking: I'd still warn once per format name per engine, not never. Silence also removes the only typo signal a server author gets through fromJsonSchema or an elicitation requestedSchema (server.ts:1224), and Ajv then accepts any string. A caller-supplied engine keeps its warnings under this PR, but the author who typed date_time never configured one. The cost of my version is one unfixable line per vendor format on each client.
Put the Set inside createDefaultAjvInstance. A module-level one would also mute a second client meeting the same name, and it would leak across the five dialect tests. Probe: one default AjvJsonSchemaValidator, two tool schemas with three google-duration fields each, then format: "date_time" validating "not a date". It's a scratch test outside the diff:
$ npx vitest run test/validators/zzprobe.test.ts
== base b022522
PROBE warnings=14 typo-valid=true formats=["google-duration","date_time"]
== PR 0210f84
PROBE warnings=0 typo-valid=true formats=[]
== once-per-name, Set per engine
PROBE warnings=2 typo-valid=true formats=["google-duration","date_time"]
The new tests discriminate, and with the per-engine Set each dialect's suppress test sees exactly two warnings:
$ npx vitest run test/validators # at 0210f84
Test Files 3 passed (3)
Tests 125 passed (125)
$ git apply -R src.diff && npx vitest run test/validators
Test Files 1 failed | 2 passed (3)
Tests 5 failed | 120 passed (125)
$ npx vitest run test/validators/ajvUnknownFormat.test.ts --reporter=json # Set per engine; failures
["unknown formats ('default')"] ['Number of calls: 2']
["unknown formats ('2020-12')"] ['Number of calls: 2']
["unknown formats ('2019-09')"] ['Number of calls: 2']
["unknown formats ('draft-07')"] ['Number of calls: 2']
["unknown formats ('draft-06')"] ['Number of calls: 2']
@felixweinberger, this is a policy call more than a code one. I would keep one line per format name for the typo signal; do you want that, or should unknown formats stay silent? The answer should bind the open v1.x fix in #2898 too.
Refs #2855 (v2).
Servers that publish unknown
formatannotations cause the v2 default Ajv validators to print warnings while compiling tool schemas. A three-field schema emits six warnings per compilation: two for each subschema path. The shared default-engine factory now filters these warnings for every supported dialect. Known formats still validate, other diagnostics still reach the console, and caller-supplied engines keep their own logging.#2898 covers the corresponding v1.x fix. This targets
mainand complements that work. #2601 also targets v2, but registersgoogle-durationspecifically; this change handles arbitrary unknown formats without adding vendor-specific validation. Both release lines need the fix, so this PR references rather than auto-closes #2855.Adapted from sean-park-funda's v2 patch, 36da288, with co-author credit. The logger stays internal, and regression coverage now exercises the default, 2020-12, 2019-09, draft-07, and draft-06 dispatch paths.
Validation:
main, each observing 12 warnings across two distinct schema compilations, and pass with the fix.core-internaltests pass, including 16 new cases covering zero warnings, duplicate diagnostics from custom engines, schema validation, known formats, and forwarding other logger messages.core-internaltypecheck and ESLint on both changed TypeScript files pass; changed files are Prettier-clean.The normal pnpm install could not access the registry in this environment. Checks used the repository's lockfile-pinned dependencies downloaded separately and verified against their integrity hashes. The full monorepo checks were not run.