Skip to content

improvement(routes): type all untyped routes - #1848

Merged
waleedlatif1 merged 4 commits into
stagingfrom
sim-361
Nov 7, 2025
Merged

improvement(routes): type all untyped routes#1848
waleedlatif1 merged 4 commits into
stagingfrom
sim-361

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • type all untyped routes
  • remove unused workspace members route
  • on workflow import, use the metadata.name and fallback to the name from the file without the UUID

Type of Change

  • Other: Code Quality

Testing

Tested manually

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

vercelBot commented Nov 7, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 7, 2025 11:06pm

@waleedlatif1
waleedlatif1 marked this pull request as ready for review November 7, 2025 23:14

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

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 extractWorkflowName to prioritize metadata.name from workflow JSON, then fallback to cleaned filename (removes UUID suffix, applies title casing)
  • Code Cleanup: Removed unused /api/workspaces/members POST 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 uploadedAt and expiresAt fields 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

FilenameScoreOverview
apps/sim/lib/workflows/import-export.ts5/5Improved 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.ts5/5Removed unused workspace members POST route
apps/sim/app/api/auth/oauth/token/route.ts5/5Added Zod schemas for request/query validation with proper error messages
apps/sim/app/api/auth/sso/register/route.ts5/5Added comprehensive Zod validation for OIDC and SAML SSO registration using discriminated unions
apps/sim/app/api/memory/[id]/route.ts5/5Added Zod validation for workflow ID query params and memory data structures
apps/sim/app/(auth)/reset-password/reset-password-form.tsx5/5Added 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
Loading

49 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
waleedlatif1 merged commit bb7016a into stagingNov 7, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the sim-361 branch November 7, 2025 23:24
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
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto 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

@waleedlatif1