GeezerVison is showing github.com — fix(execution): resolve secrets against the acting principal, not the workflow owner by icecrasher321 · Pull Request #6690 · simstudioai/sim
Conversation
Summary
- Workspace env vars now authorize against the execution actor rather than the workflow owner, so a run resolves only the secrets its caller is actually a credential member of
- Personal env vars resolve as the caller whenever one is identifiable (session, personal API key, delegated, copilot)
- Anonymous public-API runs resolve both slices as the workspace billing account. Nobody in the workspace triggered those and the endpoint is callable by anyone, so lending one human's personal namespace to it was never opted into
- The workflow-owner fallback for personal vars now applies only to workspace API keys, schedules, and webhooks — each configured by someone in the workspace, and routinely authored against the owner's personal keys
- Adds
getExecutionEnvironment, which resolves the two slices from their own identities and collapses to the single existing query when they match. If the billing account can no longer reach the workspace (billedAccountUserId is a stored column, so an org ownership transfer can strand it), it falls back to the owner and logs rather than failing every background run
- Threads
enforceCredentialAccess and isPublicApiAccess through the streaming execution path and executeWorkflowService, which build their own metadata and would otherwise disagree with the JSON path and with v2
- Marks
workflow.userId deprecated as an execution identity in the schema, documenting the one fallback that remains. It stays the ownership column everywhere else
Intentional behavior changes: runs with an identifiable caller no longer resolve workspace secrets the caller lacks credential membership for, nor personal secrets that exist only in the owner's namespace; anonymous public-API runs no longer resolve the owner's personal vars.
Type of Change
Testing
Tested manually. type-check clean; 4,500 tests across lib/workflows, lib/environment, lib/execution, lib/copilot, app/api/workflows, and app/api/v2; lint; block-registry check; all 26 audits via check:audits. check:migrations reports no new migrations — the schema change is comment-only.
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)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
greptile-apps[bot] reacted with thumbs up emoji
vercel
Bot
commented
Aug 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cursor
Bot
commented
Aug 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
PR Summary
High Risk
Changes who can see which secrets at runtime across API, streaming, async, and public endpoints—incorrect wiring would leak owner personal keys or deny production workspace secrets.
Overview
Fixes secret resolution so runs use the acting principal, not workflow.userId, for authorization and personal-env fallback.
Workspace secrets are loaded with credential membership for the execution actor (ExecutionMetadata.userId), not the workflow owner. Personal secrets come from the identifiable caller when enforceCredentialAccess is set (session, personal API key, copilot); otherwise from the workflow owner (workspace API key, schedule, webhook). Anonymous public-API runs set isPublicApiAccess and resolve no personal secrets—workspace billing principal only.
Adds getExecutionEnvironment(personalUserId, workspaceUserId, workspaceId) to merge two slices (single query when identities match; logs and falls back to the owner if the billing actor cannot access the workspace).
Path consistency: enforceCredentialAccess and isPublicApiAccess are forwarded through async enqueue, the background worker, executeWorkflowService, streaming (executeWorkflow), and pause/resume snapshot serialization. Streaming fixes streamWorkflow.userId to the owner for workflowUserId fallback (was incorrectly the actor).
Docs (credentials.mdx) and schema comments deprecate using workflow.userId as execution identity except the personal-env fallback.
Reviewed by Cursor Bugbot for commit 3c4dd6b. Configure here.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Greptile Summary
The PR separates personal-secret ownership from workspace-secret authorization so execution environments resolve against the appropriate principal across synchronous, streaming, queued, and resumed runs.
- Adds a two-identity environment resolver with an explicit workspace-access fallback for stranded billing accounts.
- Propagates caller and public-API identity decisions through execution metadata, queue payloads, and pause snapshots.
- Updates tests, shared mocks, schema documentation, and user-facing credential documentation to match the new resolution policy.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
| Filename |
Overview |
| apps/sim/lib/environment/utils.ts |
Introduces split-principal environment resolution and narrows the owner fallback to an explicit workspace-access denial. |
| apps/sim/lib/workflows/executor/execution-core.ts |
Selects personal and workspace environment identities from execution metadata and applies the combined environment snapshot. |
| apps/sim/app/api/workflows/[id]/execute/route.ts |
Propagates caller-authorization and anonymous-public-API decisions consistently across sync, stream, and async execution. |
| apps/sim/background/workflow-execution.ts |
Preserves identity decisions in queued execution payloads so workers resolve secrets consistently with request-bound paths. |
| apps/sim/executor/execution/snapshot-serializer.ts |
Persists both identity flags across human-in-the-loop pause and resume. |
| packages/testing/src/mocks/environment-utils.mock.ts |
Recomputes conflict and decryption-failure metadata from the retained personal and workspace slices, addressing the previous mock-divergence finding. |
| packages/db/schema.ts |
Adds documentation clarifying that workflow ownership is not generally an execution identity; no database shape changes are introduced. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Trigger[Execution trigger] --> Identity{Identifiable caller?}
Identity -->|Yes| Caller[Caller identity]
Identity -->|No| Billing[Workspace billing account]
Caller --> Personal[Resolve personal secrets as caller]
Caller --> Workspace[Authorize workspace secrets as caller]
Billing --> Public{Anonymous public API?}
Public -->|Yes| NoPersonal[No personal-secret slice]
Public -->|No| Owner[Resolve personal secrets as workflow owner]
Billing --> WorkspaceBilling[Authorize workspace secrets as billing account]
WorkspaceBilling --> Access{Workspace access?}
Access -->|Yes| Merge[Merge personal and workspace slices]
Access -->|No| OwnerFallback[Resolve both slices as workflow owner]
Personal --> Merge
Workspace --> Merge
NoPersonal --> Merge
Owner --> Merge
OwnerFallback --> Merge
Loading
Reviews (2): Last reviewed commit: "fix(execution): propagate run identity a..." | Re-trigger Greptile
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…e public runs to workspace secrets
greptile-apps[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cursor[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this 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 3c4dd6b. Configure here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This branch was successfully deployed
1 active
deployment
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|