Skip to content

feat(start-block): add run metadata toggle with trusted <start.metadata> outputs#5700

Merged
TheodoreSpeaks merged 5 commits into
stagingfrom
feat/start-block-metadata
Jul 16, 2026
Merged

feat(start-block): add run metadata toggle with trusted <start.metadata> outputs#5700
TheodoreSpeaks merged 5 commits into
stagingfrom
feat/start-block-metadata

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Add an "Add run metadata" toggle to the Start block (under Show additional fields, default off) exposing a server-injected <start.metadata> object: userEmail, workspaceId, workflowId, executionId, executionType, executionMode, startTime
  • Every field describes the invoking run — inside a custom block they're the consumer's email/workspace/workflow, so the published workflow can trust who called it
  • The metadata key is server-owned when the toggle is on: caller-supplied values are stripped and overwritten, an input format field named metadata fails fast, toggle-off behavior is byte-identical
  • Actor email resolves via one lazy user lookup in executeWorkflowCore; child/custom-block metadata is built at the invocation boundary in workflow-handler

Type of Change

  • New feature

Testing

Unit tests for spoof-override, fail-closed, and name-collision behavior + tag-dropdown schema paths + custom-block caller identity. Lint, typecheck, and check:api-validation:strict pass.

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

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 16, 2026 2:25am

Request Review

@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches execution context and Start output shaping (including PII via user email) with spoof-resistance rules; scope is bounded by an opt-in toggle and covered by extensive unit tests.

Overview
Adds an advanced Add run metadata switch on the Start block (default off). When enabled, the executor injects a server-built metadata object on Start output (userEmail, workspaceId, workflowId, executionId, executionType, executionMode, startTime) for references like <start.metadata.*>; fields always describe the invoking run (e.g. custom-block consumers see caller identity, not the published workflow).

executeWorkflowCore builds startRunMetadata from the authenticated context (including a fail-soft getUserEmailById lookup). workflow-handler builds or inherits the same payload for child/custom-block runs, including resume recovery from seeded Start output and pass-through when an intermediate child has the toggle off. buildStartBlockOutput applies trusted metadata only when the toggle is on: strips spoofed caller metadata, omits the key if none is trusted, and errors on an input-format field named metadata. Block output schemas expose metadata.* paths only when the toggle is on.

Reviewed by Cursor Bugbot for commit a5b3519. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread apps/sim/executor/handlers/workflow/workflow-handler.ts
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds optional trusted run metadata to the Start block. The main changes are:

  • Adds an advanced toggle for exposing run metadata.
  • Injects server-owned metadata while removing caller-supplied overrides.
  • Propagates invoking-run identity through child and custom-block workflows.
  • Preserves metadata through resumed and nested executions.
  • Adds matching output-schema paths and focused tests.

Confidence Score: 5/5

This looks safe to merge.

  • Email lookup errors now return a nullable value without stopping workflow execution.
  • Resumed executions retain the seeded Start block metadata.
  • No blocking issue remains in the updated code.

Important Files Changed

Filename Overview
apps/sim/lib/users/queries.ts Adds a fail-soft email lookup for optional run metadata.
apps/sim/lib/workflows/executor/execution-core.ts Builds top-level run metadata for metadata-enabled Start blocks.
apps/sim/executor/handlers/workflow/workflow-handler.ts Propagates invoking-run metadata through child, custom-block, nested, and resumed executions.
apps/sim/executor/utils/start-block.ts Reserves the metadata output and injects only server-provided values when enabled.
apps/sim/lib/workflows/blocks/block-outputs.ts Exposes the conditional metadata object and its nested output paths.

Reviews (4): Last reviewed commit: "fix(start-block): recover metadata chain..." | Re-trigger Greptile

Comment thread apps/sim/lib/workflows/executor/execution-core.ts
Comment thread apps/sim/lib/workflows/executor/execution-core.ts
Comment thread apps/sim/lib/workflows/blocks/block-outputs.ts Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/executor/handlers/workflow/workflow-handler.ts Outdated
Comment thread apps/sim/executor/handlers/workflow/workflow-handler.ts Outdated
Comment thread apps/sim/lib/workflows/blocks/block-outputs.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/lib/workflows/executor/execution-core.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a5b3519. Configure here.

Comment thread apps/sim/lib/workflows/executor/execution-core.ts
@TheodoreSpeaks
TheodoreSpeaks merged commit f5a6c47 into staging Jul 16, 2026
18 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the feat/start-block-metadata branch July 16, 2026 07:42
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