fix(mcp): Fix default(null) injection in generated tool schemas that allow null#61072
Merged
Conversation
Contributor
|
Size Change: 0 B Total Size: 81 MB ℹ️ View Unchanged
|
Contributor
|
Reviews (1): Last reviewed commit: "Regenerate files" | Re-trigger Greptile |
webjunkie
approved these changes
Jun 2, 2026
Contributor
webjunkie
left a comment
There was a problem hiding this comment.
Reviewed and approved!
This was referenced Jun 2, 2026
webjunkie
added a commit
that referenced
this pull request
Jun 2, 2026
Call stripNullDefaults from preprocessSchema directly so every codegen pipeline that goes through @posthog/openapi-codegen gets the cleanup, not just the frontend orchestrator. Removes the now-redundant explicit call from frontend/bin/generate-openapi-types.mjs. Regenerates MCP outputs as a side effect — same cleanup #61072 targets, just landing here too. Whichever PR merges first wins the race for the generated files; the other rebases to a zero-diff state. Marcel's MCP-local schemaAllowsNull and stripNullDefaults become dead code once both land — small follow-up to swap his locals for shared imports.
webjunkie
added a commit
that referenced
this pull request
Jun 3, 2026
…lper Now that #61072 has landed, the MCP-local schemaAllowsNull and stripNullDefaults in generate-orval-schemas.mjs are dead code — the shared preprocessSchema runs first on the full schema and covers every shape they did plus the untyped-Any case (bare {} from typing.Any), which the local helper missed. Regen produces zero diff against the merged tree, since the shared pass already cleaned the same outputs Marcel's local strip was targeting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
In "tools" mode the MCP server validates arguments with
schema.safeParse(...), which applies Zod defaults. Nullable-optional fields carried.default(null)(from the OpenAPI codegen), so any field the caller omitted was filled withnull.For experiment metrics, a discriminated union where each variant forbids unknown fields, this meant a clean metric arrived with every other variant's fields set to null and was rejected as
extra_forbidden. Adding/updating a metric viaexperiment-updatefailed for tool-mode clients.The
stripNullDefaultscodegen step that should prevent this only handled OpenAPI 3.0nullable: true, missing the 3.1anyOf: [..., { type: "null" }]shape pydantic emits.Changes
stripNullDefaultsto match all nullability shapesHow did you test this code?
tsccleandefault: nullremovals — zerorequiredadditions, zero.default(...)additions🤖 Agent context
Authored with Claude Code (Opus 4.8). Root-cause fix in the codegen; rejected backend
extra="ignore"and handler-level null-stripping as treating the symptom. Agent-authored; requires human review.