Skip to content

fix(resume): require write access to resume a paused run on the legacy route - #8896

Open
waleedlatif1 wants to merge 7 commits into
stagingfrom
fix/resume-post-write-authz
Open

waleedlatif1 wants to merge 7 commits into
stagingfrom
fix/resume-post-write-authz

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Legacy POST /api/resume/[workflowId]/[executionId]/[contextId] authorized through validateWorkflowAccess, which only checks workspace read, so a read-only member or their API key could answer a human-in-the-loop pause and continue the run with their own input
  • The route now authenticates with internalWorkflowSessionOrApiKeyAuth and runs resumeWorkflowRun, the same workflows.runs.resume operation (write role) the v2 resume route uses, which also brings the run-to-workflow scope check and cross-tenant concealment
  • resumeWorkflowRun takes the calling surface (legacy | v2) so the legacy route keeps streaming and job-id polling, and forwards the request signal/headers a streamed resume needs
  • Inlined the single-consumer resume-handler.ts presenter into the route, keeping its legacy-only "failed sync run → 400 { error }" answer; the GET detail handler stays read
  • Response contract changes on the legacy route: an unexpected server fault (malformed snapshot, run buffer unavailable, DB error) now returns a generic 500 instead of a 400 echoing the raw message; typed admission failures keep their 4xx. OAuth and delegated principals are now treated as API callers (previously only API keys)

Type of Change

  • Bug fix

Testing

  • Regression tests: a read-role member gets 403 from the legacy POST over session and personal-API-key auth, and nothing is enqueued; they go red when resumeRun is lowered to read
  • The legacy failed-sync-run 400 test goes red when the ported branch is removed
  • [contextId]/route.test.ts, resume/poll/route.test.ts, run-control.test.ts, v2 resume/route.test.ts (53/53)
  • bun run lint; generators in sync; remaining audits, type-check, and the full suite run in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

…y route

POST /api/resume/[workflowId]/[executionId]/[contextId] authorized with
validateWorkflowAccess, which checks workspace read permission, so a
read-only member (or their API key) could answer a human-in-the-loop pause
and continue the run with arbitrary input. The route now authenticates with
the internal workflow session/API-key policy and runs the resumeWorkflowRun
use case, the same write-role operation the v2 resume route uses.

resumeWorkflowRun takes the calling surface ('legacy' | 'v2') so the legacy
route keeps its streaming and job-id polling responses, and forwards the
request signal and headers a streamed resume needs.
@vercel

vercel Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 15, 2026 1:15am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 8 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/api/resume/[workflowId]/[executionId]/[contextId]/route.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The PR appears safe to merge; no actionable new issues were found.

Summary

The legacy resume POST now requires write access through resumeWorkflowRun, while keeping streaming and job polling.

  • Legacy resume requests now require workspace write access.
  • Legacy resume responses separate failed runs from server faults.
  • The project file-search query schema stays local to its contract.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Legacy[Legacy resume POST] --> Auth[Authenticate caller]
  V2[V2 resume POST] --> Auth
  Auth --> Gate[Check run scope and write access]
  Gate --> Resume[resumeWorkflowRun]
  Resume --> Executor[Continue paused run]
  Executor --> LegacyResponse[Legacy stream or JSON response]
  Executor --> V2Response[V2 JSON response]
Loading

Reviews (4) · Last reviewed commit: "fix(resume): withhold unsafe resume fail..." · Reviewed by Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Turn on auto-fix | Re-trigger cubic

…ite-authz

# Conflicts:
#	apps/sim/app/api/resume/[workflowId]/[executionId]/[contextId]/route.test.ts
#	apps/sim/app/api/resume/resume-handler.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 8 files

Confidence score: 3/5

  • In resume-run.ts, session-authenticated legacy requests now return started after launching detached work, bypassing the API execution modes and potentially breaking streaming, synchronous failure responses, and async job-ID handling. Preserve the execution-mode behavior for these requests.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/sim/lib/workflows/application/resume-run.ts">

<violation number="1" location="apps/sim/lib/workflows/application/resume-run.ts:35">
P1: Session-authenticated legacy requests now bypass the API execution-mode branches and return `started` after launching detached work, instead of preserving streaming, synchronous failure responses, and async job-ID polling. Treat legacy requests as API callers regardless of principal kind.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/workflows/application/resume-run.ts
Also drop two unused exports from the v2 Project file search contract that fail check:unused-exports on staging.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

This branch was previously deployed

1 inactive deployment
Preview — 224476ad Deployed Oct 15, 2026 by vercel[bot]
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