improvement(routes): type all untyped routes#1848
Merged
waleedlatif1 merged 4 commits intostagingfrom Nov 7, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR systematically adds type safety to 49 API route handlers by introducing Zod validation schemas, removes an unused workspace members POST endpoint, and improves the workflow import naming logic.
Key Changes
- Route Typing: Added Zod schemas to validate request bodies, query parameters, and path parameters across all API routes, replacing manual validation with structured error messages
- Workflow Import Enhancement: Modified
extractWorkflowNameto prioritizemetadata.namefrom workflow JSON, then fallback to cleaned filename (removes UUID suffix, applies title casing) - Code Cleanup: Removed unused
/api/workspaces/membersPOST route (the/api/workspaces/members/[id]DELETE route remains for member removal) - Password Validation: Enhanced client-side password requirements with length limits and character complexity checks
- Test Maintenance: Removed obsolete
uploadedAtandexpiresAtfields from test fixtures
The changes follow a consistent pattern: parse with Zod schema → extract first error on failure → return structured error response. This improves API contract enforcement and provides clearer validation feedback to clients.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes are purely additive type safety improvements using industry-standard Zod validation. All route handlers follow a consistent validation pattern, the workflow naming logic has proper fallbacks, and the removed endpoint was unused. Manual testing confirmed functionality.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/workflows/import-export.ts | 5/5 | Improved extractWorkflowName to use metadata.name from workflow JSON, fallback to formatted filename with UUID removal and title casing |
| apps/sim/app/api/workspaces/members/route.ts | 5/5 | Removed unused workspace members POST route |
| apps/sim/app/api/auth/oauth/token/route.ts | 5/5 | Added Zod schemas for request/query validation with proper error messages |
| apps/sim/app/api/auth/sso/register/route.ts | 5/5 | Added comprehensive Zod validation for OIDC and SAML SSO registration using discriminated unions |
| apps/sim/app/api/memory/[id]/route.ts | 5/5 | Added Zod validation for workflow ID query params and memory data structures |
| apps/sim/app/(auth)/reset-password/reset-password-form.tsx | 5/5 | Added client-side password validation for length, uppercase, lowercase, numbers, and special characters |
Sequence Diagram
sequenceDiagram
participant User
participant CreateMenu
participant extractWorkflowName
participant WorkflowJSON
participant Filename
User->>CreateMenu: Upload workflow file(s)
CreateMenu->>extractWorkflowName: Call with content & filename
alt JSON parse succeeds
extractWorkflowName->>WorkflowJSON: Parse JSON content
alt metadata.name exists
WorkflowJSON-->>extractWorkflowName: Return state.metadata.name
extractWorkflowName-->>CreateMenu: Return metadata name
else metadata.name missing
extractWorkflowName->>Filename: Process filename
Filename->>Filename: Remove .json extension
Filename->>Filename: Remove UUID suffix pattern
Filename->>Filename: Replace dashes/underscores with spaces
Filename->>Filename: Apply title casing
Filename-->>extractWorkflowName: Return formatted name
extractWorkflowName-->>CreateMenu: Return formatted filename
end
else JSON parse fails
extractWorkflowName->>Filename: Process filename
Filename->>Filename: Remove .json extension
Filename->>Filename: Remove UUID suffix pattern
Filename->>Filename: Replace dashes/underscores with spaces
Filename->>Filename: Apply title casing
Filename-->>extractWorkflowName: Return formatted name or "Imported Workflow"
extractWorkflowName-->>CreateMenu: Return formatted filename
end
CreateMenu->>CreateMenu: Create workflow with extracted name
49 files reviewed, no comments
waleedlatif1
added a commit
that referenced
this pull request
Nov 9, 2025
* improvement(routes): type all untyped routes * fix routes, remove unused workspace members route * fix obfuscation of errors behind zod errors * remove extraneous comments
waleedlatif1
added a commit
that referenced
this pull request
Nov 12, 2025
* improvement(routes): type all untyped routes * fix routes, remove unused workspace members route * fix obfuscation of errors behind zod errors * remove extraneous comments
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.
Summary
Type of Change
Testing
Tested manually
Checklist