Skip to content

Replace custom jsonSchemaToZod implementation with Zod's native z.fromJSONSchema() method#1735

Merged
dimaMachina merged 65 commits intomainfrom
prd-5966
Feb 5, 2026
Merged

Replace custom jsonSchemaToZod implementation with Zod's native z.fromJSONSchema() method#1735
dimaMachina merged 65 commits intomainfrom
prd-5966

Conversation

@dimaMachina
Copy link
Collaborator

No description provided.

dimaMachina and others added 30 commits February 4, 2026 11:44
…mary (#1714)

- Add `url` field to GraphQL queries for review threads and PR comments
- Add Phase 5.4 to capture inline comment URLs after posting
- Update Point-Fix Edits section to include clickable links
- Update Pending Recommendations to use URLs from pr-context skill
- Add `gh api` to allowed tools for fetching comment URLs
- Add secure debug artifact uploads for Claude review runs
SDK versions 0.2.27+ have a bug causing AJV validation crashes
before any API calls are made. This affects all PR reviews.

Tracking issue: anthropics/claude-code-action#892
Related: #852, #880, #804

Will revert to @v1 when the upstream issue is resolved.
…hemas containing refinements` error (#1712)

* Revert "fix(agents-core): remove refine call in resource id schema (#1689)"

This reverts commit 938ffb8.

* Revert "fix(agents-core): remove refine call in resource id schema (#1689)"

This reverts commit 938ffb8.

* bump

* upd

* remove zod from pnpm overrides

* update zod peerdependencies too, and we have error reproducible locally

* minimal fix

* rm unrelated changes

* rm unrelated changes

* rm unrelated changes

* rm unrelated changes

* rm unrelated changes

* rm unrelated changes

* rm unrelated changes

* rm unrelated changes
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat: add Vercel production deployment workflow

Add GitHub Actions workflow to deploy to Vercel production only when
a GitHub release is published. This integrates with the existing
changesets release flow.

* feat: add deployment checks before promoting to production

Deploy to preview URL first, wait for Vercel deployment checks to pass,
then promote to production. This ensures API health before going live.

* PRD for vercel deployment strategy

* docs: add Vercel staging/production deployment strategy documentation

- Document Production Branch configuration (set to '_disabled_')
- Document GitHub Actions workflow for release-triggered deployments
- Document required secrets (VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID)
- Document optional staging domain configuration
- Add deployment flow diagram and troubleshooting section
- Add secrets documentation comments to workflow file

Completes US-001, US-002, US-003, US-004 from vercel-deployment-strategy PRD.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update Vercel staging/production strategy to use never-deploy branch

Replace _disabled_ approach (which Vercel doesn't support) with a
never-deploy orphan branch. Update staging domain examples to use
api-staging.agents.yourdomain.com pattern.

* Apply suggestion from @claude[bot]

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>

* revert: remove Vercel deployment docs changes and PRD

Revert vercel.mdx to main branch version and remove the PRD file.

* feat: deploy both agents-api and agents-manage-ui to Vercel

Update production workflow to deploy both projects in parallel using a
matrix strategy. Each project uses its own secret for the Vercel project ID.

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
No-op patch bumps to trigger a new release.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…1721)

The vercel inspect and promote commands were failing with authorization
errors because VERCEL_ORG_ID as an environment variable isn't used by
the CLI for scope resolution - it requires the --scope flag explicitly.
Comment on lines +71 to +73
const mockDataSchema = artifactComponent.props
? z.fromJSONSchema(artifactComponent.props)
: z.string();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dimaMachina
Copy link
Collaborator Author

@claude write a changeset based on changes in this PR

@claude
Copy link
Contributor

claude bot commented Feb 5, 2026

Claude finished @dimaMachina's task in 2m 51s —— View job


✅ Changeset Created

I've created and pushed a changeset for this PR that documents the removal of the custom jsonSchemaToZod implementation.

Todo List

  • Review the PR changes to understand the scope
  • Determine affected packages and appropriate version bump
  • Create changeset using pnpm bump command
  • Commit and push the changeset

Changeset Details

File: .changeset/tidy-foxes-refactor.md

Packages affected:

  • @inkeep/agents-api: patch
  • @inkeep/agents-core: patch

Description: Replace custom jsonSchemaToZod implementation with Zod's native z.fromJSONSchema() method

This is an internal refactoring that removes ~200 lines of duplicate code by leveraging Zod's built-in JSON Schema conversion functionality. The change has no user-facing API impact, hence the patch version bump.

Replace custom implementation with Zod's native z.fromJSONSchema() method

Co-authored-by: Dimitri POSTOLOV <dimaMachina@users.noreply.github.com>
@dimaMachina dimaMachina marked this pull request as ready for review February 5, 2026 15:12
@dimaMachina dimaMachina changed the title Prd 5966 Replace custom jsonSchemaToZod implementation with Zod's native z.fromJSONSchema() method Feb 5, 2026
Base automatically changed from prd-4917 to main February 5, 2026 16:40
@claude
Copy link
Contributor

claude bot commented Feb 5, 2026

Claude finished @dimaMachina's task in 51s —— View job


PR Review Summary (Review #4)

1 Key Finding | Risk: Low

This is a solid refactoring PR that replaces ~200 lines of duplicate jsonSchemaToZod() implementations with Zod's native z.fromJSONSchema(). The architectural decision is sound.

🟠🔶⚠️ Major (1) 🟠🔶⚠️

🕐 Pending from previous reviews:

Agent.ts:1396-1398 Missing try-catch for user-controlled inputSchemafunctionData.inputSchema bypasses JSON Schema validation at the API layer (only validates as z.record(z.string(), z.unknown())). A 1-click fix suggestion is already posted.

✅ Improvements Since Last Review

  • Null checks added (? ... : z.string()) at Agent.ts:1396 and Agent.ts:3660
  • Explicit JSONSchema.BaseSchema type annotations in artifact-component-schema.ts
  • Changeset created documenting the change

📌 Point-fix Edits


💡 APPROVE WITH SUGGESTIONS

Summary: Architecturally sound cleanup. The one remaining gap — error handling at Agent.ts:1396 — has a 1-click suggestion ready. Accept or dismiss at your discretion; all other call sites have proper error handling or sufficient upstream validation.

Other Findings (4)

Validation by location (for reference)

Location Risk Reason
Agent.ts:2198-2214 ✅ NONE Already has try-catch
Agent.ts:3660 ✅ LOW dc.props validated via validatePropsAsJsonSchema() at API layer
artifact-component-schema.ts:38 ✅ NONE Static hardcoded constant
artifact-component-schema.ts:106 ✅ LOW Programmatically constructed from validated inputs
EvaluationService.ts:1073 ✅ NONE Already has try-catch
manage-ui/validation.ts:45 ✅ NONE Already has try-catch
manage-ui routes ✅ LOW Upstream API validates props

@vercel vercel bot temporarily deployed to Preview – agents-docs February 5, 2026 18:59 Inactive
@claude
Copy link
Contributor

claude bot commented Feb 5, 2026

Claude finished @dimaMachina's task in 3m 41s —— View job


PR Review Summary (Review #5)

1 Key Finding | Risk: Low

This is an architecturally sound cleanup PR that removes ~180 lines of duplicate code by replacing custom jsonSchemaToZod() implementations with Zod's native z.fromJSONSchema().

🟠🔶⚠️ Major (1) 🟠🔶⚠️

🕐 Pending from previous reviews:

Agent.ts:1395-1397 Missing try-catch for user-controlled inputSchema

Issue: functionData.inputSchema has no upstream JSON Schema validation — the API only validates it as z.record(z.string(), z.unknown()). Malformed schemas (invalid type combinations, unsupported keywords) will cause z.fromJSONSchema() to throw.

Why: The author's null check (? ... : z.string()) handles undefined/null, but not malformed schemas. When this throws, getFunctionTools() fails and returns empty tools — a silent failure that's hard to debug.

Fix: A 1-click suggestion was posted in review #3. The same pattern is already used at line 2198-2214 for MCP overrides.

✅ Validation by Location

My exploration confirmed the risk assessment from previous reviews:

Location Risk Reason
Agent.ts:1395-1397 ⚠️ MEDIUM No upstream JSON Schema validation
Agent.ts:2198-2214 ✅ NONE Already has try-catch
Agent.ts:3659 ✅ LOW dc.props validated via validatePropsAsJsonSchema() at API + DAL layer
artifact-component-schema.ts:38 ✅ NONE Static hardcoded constant (ARTIFACT_PROPS_SCHEMA)
artifact-component-schema.ts:106 ✅ LOW Programmatically constructed from validated inputs
EvaluationService.ts:1072-1085 ✅ NONE Already has try-catch
manage-ui/validation.ts:45 ✅ NONE Already has try-catch

📌 Point-fix Edits


💡 APPROVE WITH SUGGESTIONS

Summary: Clean refactor with correct architectural direction. The one remaining gap at Agent.ts:1395 has a 1-click suggestion ready. Given the PR is already approved and the risk is contained to function tools with invalid inputSchema (an edge case), this is ready to merge. Accept the inline suggestion at your discretion.

Other Findings (3)

Discarded as invalid or not applicable

Location Issue Reason Excluded
Test coverage Single test case for z.fromJSONSchema Zod's native implementation is well-tested; the test validates integration
agents-cli Uses json-schema-to-zod Different npm package (generates code strings, not runtime types) — unrelated
package.json Dependency changes zod-from-json-schema correctly removed — no longer needed

@claude
Copy link
Contributor

claude bot commented Feb 5, 2026

Claude finished @dimaMachina's task in 52s —— View job


PR Review Summary (Review #6)

1 Key Finding | Risk: Low

This PR cleanly removes ~180 lines of duplicate jsonSchemaToZod() implementations in favor of Zod's native z.fromJSONSchema(). The architectural decision is sound.

🟠🔶⚠️ Major (1) 🟠🔶⚠️

🕐 Pending from previous reviews:

Agent.ts:1395-1397 Missing try-catch for user-controlled inputSchema — A 1-click suggestion is posted. Same pattern is already used at line 2198-2214.

📌 Point-fix Edits


💡 APPROVE WITH SUGGESTIONS

Summary: Solid cleanup PR. The one pending suggestion has been reviewed 5 times and a 1-click fix is available. Accept or dismiss at your discretion — all other call sites have proper error handling or sufficient upstream validation. Ready to merge. 🚀

Other Findings (3)

Validation by location

Location Risk Reason
Agent.ts:2198-2214 ✅ NONE Already has try-catch
Agent.ts:3659 ✅ LOW dc.props validated via validatePropsAsJsonSchema()
artifact-component-schema.ts:38 ✅ NONE Static hardcoded constant
artifact-component-schema.ts:106 ✅ LOW Constructed from validated inputs
EvaluationService.ts:1072-1085 ✅ NONE Already has try-catch
manage-ui/validation.ts:45 ✅ NONE Already has try-catch

@dimaMachina dimaMachina marked this pull request as ready for review February 5, 2026 19:48
@dimaMachina dimaMachina merged commit 632d68d into main Feb 5, 2026
8 checks passed
@dimaMachina dimaMachina deleted the prd-5966 branch February 5, 2026 19:48
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.

4 participants

Comments