Skip to content

Conversation

@waleedlatif1
Copy link
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
Copy link

vercel bot commented Nov 7, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Nov 7, 2025 11:06pm

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

@greptile-apps greptile-apps bot left a 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 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

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
Loading

49 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit bb7016a into staging Nov 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
@waleedlatif1 waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
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.

2 participants