-
Notifications
You must be signed in to change notification settings - Fork 3.1k
improvement(routes): type all untyped routes #1848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
* improvement(routes): type all untyped routes * fix routes, remove unused workspace members route * fix obfuscation of errors behind zod errors * remove extraneous comments
* improvement(routes): type all untyped routes * fix routes, remove unused workspace members route * fix obfuscation of errors behind zod errors * remove extraneous comments
Summary
Type of Change
Testing
Tested manually
Checklist