Skip to content

improvement(repo): centralized zod contracts#4336

Merged
icecrasher321 merged 11 commits intodevfrom
improvement/zod-typing-consol
Apr 29, 2026
Merged

improvement(repo): centralized zod contracts#4336
icecrasher321 merged 11 commits intodevfrom
improvement/zod-typing-consol

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

@icecrasher321 icecrasher321 commented Apr 29, 2026

Summary

  • Client-Server boundary must respect Zod contracts.
  • Migration to zod v4
  • CI check to enforce boundary violations
  • Update skills
  • Split up selectors code to match repo structure
  • Cleanup route local schemas and client component arbitrary types

Type of Change

  • Other: Code Structure Improvement

Testing

IN PROGRESS -- to be tested in dev environment

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 29, 2026 4:45pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Medium Risk
Touches many API routes’ request parsing/validation paths and upgrades Zod semantics (issues/formatting), so subtle behavior changes in 400s and schema parsing are possible despite being largely mechanical.

Overview
Enforces a contract-first HTTP boundary policy: routes under apps/sim/app/api/** are updated to stop defining route-local Zod schemas and instead validate params/query/body via shared schemas/contracts in apps/sim/lib/api/contracts/** using canonical helpers like parseRequest, validateSchema, and validateJsonBody (with improved, consistent 400 error messaging).

Adds enforcement and guidance: CI now runs bun run check:api-validation:strict and developer docs/agent skills/cursor rules are expanded to codify the boundary rules (including limited, reason-required annotations for legitimate raw fetch/double-cast exceptions).

Zod v4 migration follow-ups and small correctness fixes: realtime bumps zod to 4.3.6 and updates error formatting/access (treeifyError, issues), numerous API routes switch from error.errors to error.issues, the academy certificate page replaces a double-cast with schema-validated metadata, landing forms use a shared flattenFieldErrors helper and remove a Combobox double-cast, and a realtime variable update bug is fixed (workflowId source).

Reviewed by Cursor Bugbot for commit 25d4d0b. Configure here.

Comment thread apps/sim/lib/api/contracts/chats.ts
Comment thread apps/sim/app/api/a2a/serve/[agentId]/route.ts Outdated
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/api/contact/route.ts
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/lib/api/contracts/selectors/wealthbox.ts
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/api/admin/mothership/route.ts
Comment thread apps/realtime/src/database/operations.ts
Comment thread apps/sim/app/api/auth/trello/authorize/route.ts Outdated
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/api/auth/oauth/wealthbox/item/route.ts
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 25d4d0b. Configure here.

@icecrasher321 icecrasher321 merged commit ed1a875 into dev Apr 29, 2026
14 checks passed
icecrasher321 added a commit that referenced this pull request Apr 30, 2026
* improvement(repo): centralized zod contracts (#4336)

* improvement(repo): zod schema contracts

* type checks

* fix(notion): correctly register tool (#4337)

* fix func blokc

* more improvements

* fix tests

* type check

* remove v3 refs

* minor type improvements

* address comments

* update jira contract

* remove validateJsonBody

* improvement(repo): consolidation of boundary helpers + better unknown usage (#4352)

* improvement(repo): consolidation of boundary helpers + better unknown usage

* address comments

* improve file transfer error messaging

* fix docs listing schema drift

* fix inocrrect type casting

* address council comments

* remove prefix
@waleedlatif1 waleedlatif1 deleted the improvement/zod-typing-consol branch April 30, 2026 21:50
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.

1 participant