Skip to content

fix(logs): relax fileSchema so execution logs with files render again#4495

Merged
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/kathmandu-v2
May 7, 2026
Merged

fix(logs): relax fileSchema so execution logs with files render again#4495
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/kathmandu-v2

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Make uploadedAt and expiresAt optional in fileSchema so contract validation passes for execution log rows whose files (written by extractFilesFromExecution and execution-file-manager) don't include those fields
  • Mirror in the local FileData type in file-download.tsx; switch its template literal className to cn()

Before this fix, useLogDetail was throwing ApiClientError("Response failed contract validation") on any workflow log with files, the query fell back to the list row (no files), and <FileCards> never rendered.

Type of Change

  • Bug fix

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
Copy Markdown

vercel Bot commented May 7, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 7, 2026 7:35pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 7, 2026

PR Summary

Low Risk
Low risk bug fix that mainly adjusts Zod contract schemas/types and a small UI className change; primary risk is inadvertently accepting malformed file metadata due to added defaults/passthrough.

Overview
Fixes log detail contract validation failures for executions that include files by introducing a canonical userFileSchema in contracts/primitives.ts (with defaults and .passthrough()) and using it for workflowLogDetailSchema.files.

Deduplicates media tool contracts by switching STT/video file inputs from the removed mediaUserFileSchema to userFileSchema, and updates the logs UI file components to use the shared UserFile type plus cn() for className composition.

Reviewed by Cursor Bugbot for commit 409ea56. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR fixes a contract-validation regression that prevented execution logs with files from rendering in the logs UI. The root cause was a local fileSchema in logs.ts that required uploadedAt and expiresAt — fields absent from execution-log file rows — causing useLogDetail to throw on every affected response.

  • primitives.ts: Introduces a canonical userFileSchema (with .passthrough() to absorb legacy fields) that consolidates the previously duplicated mediaUserFileSchema from tools/media/shared.ts.
  • logs.ts: Replaces the inline fileSchema with userFileSchema, removing the required uploadedAt/expiresAt that triggered validation failures.
  • file-download.tsx: Drops the local FileData interface in favour of UserFile from executor/types, aligning the UI type with the executor's source-of-truth, and adopts cn() for className composition.

Confidence Score: 5/5

Safe to merge — the change removes an over-strict validation constraint that was actively breaking a feature, consolidates duplicated schema definitions, and aligns the UI type with its authoritative source.

All changed code is narrowly scoped to schema consolidation and type alignment. The .passthrough() approach correctly handles stored rows that may carry legacy fields without rejecting valid payloads, and the UserFile interface in executor/types.ts matches the userFileSchema output shape. No logic paths, data mutations, or auth flows are affected.

No files require special attention. The only minor note is a cosmetic JSDoc ordering issue in primitives.ts.

Important Files Changed

Filename Overview
apps/sim/lib/api/contracts/primitives.ts Adds canonical userFileSchema with .passthrough() to tolerate legacy fields; a pre-existing JSDoc comment for booleanQueryFlagSchema is now orphaned between two schemas
apps/sim/lib/api/contracts/logs.ts Drops the inline fileSchema with required uploadedAt/expiresAt and switches to the shared userFileSchema, fixing contract-validation failures on execution logs with files
apps/sim/lib/api/contracts/tools/media/shared.ts Removes mediaUserFileSchema, now replaced by the canonical userFileSchema in primitives.ts
apps/sim/lib/api/contracts/tools/media/stt.ts Updates import source for the file schema from shared.ts to primitives.ts; behaviour unchanged
apps/sim/lib/api/contracts/tools/media/video.ts Same import path update as stt.ts; visualReference now validates against the canonical schema
apps/sim/app/workspace/[workspaceId]/logs/components/log-details/components/file-download/file-download.tsx Drops local FileData interface in favour of UserFile from executor types; adds cn() for className merging

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Execution log API response\ncontains files array] --> B{Contract validation\nuserFileSchema}
    B -->|uploadedAt / expiresAt absent\nBEFORE fix: FAIL| C[ApiClientError\nResponse failed contract validation]
    B -->|passthrough tolerates\nextra / missing fields\nAFTER fix: PASS| D[WorkflowLogDetail\nwith files array]
    D --> E[useLogDetail hook\nreturns data]
    E --> F[FileCards rendered\nin log details UI]
    C --> G[Query falls back to\nlist row — no files field]
    G --> H[FileCards never rendered]

    style C fill:#f88,stroke:#c00
    style H fill:#f88,stroke:#c00
    style D fill:#8f8,stroke:#080
    style F fill:#8f8,stroke:#080
Loading

Reviews (2): Last reviewed commit: "improvement(contracts): promote userFile..." | Re-trigger Greptile

- contracts/logs.ts: replace local fileSchema with mediaUserFileSchema (the established UserFile boundary schema with .passthrough())
- file-download.tsx: drop local FileData interface, use UserFile from @/executor/types
Move the canonical UserFile boundary schema out of tools/media/shared.ts
(where it didn't belong — logs aren't media tools) into primitives.ts as
userFileSchema. Update logs, stt, and video contracts to import from the
shared primitive.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

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 409ea56. Configure here.

@waleedlatif1 waleedlatif1 merged commit d081ab2 into staging May 7, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/kathmandu-v2 branch May 7, 2026 19:54
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