Skip to content

fix(workflow): record the verified caller as owner of /workflow/execute workflows (#20585) - #21235

Closed
mrveiss wants to merge 2 commits into
mainfrom
issue-20585
Closed

mrveiss wants to merge 2 commits into
mainfrom
issue-20585

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #20585

Thinking Path

Since #19807 a workflow command step runs as its creator and is refused when none is recorded. On current main, three of the four creators named in the issue already record an owner; only POST /workflow/execute did not.

Single-issue rationale

One defect: a creator that has a verified caller but drops it. Fixed once, with tests for all four creators.

What Changed

  • api/workflow.py: execute_workflow takes get_current_user and passes caller_id(current_user) (the verified caller, never the body) to the complex-request path. _execute_complex_workflow moved to api/workflow_complex.py because api/workflow.py is over its size ceiling and may not grow. The body is unchanged apart from one addition: a new owner_id parameter, forwarded to create_workflow_from_chat_request.
  • services/workflow_automation/creator_owner_20585_test.py: per creator, an admin caller's recorded owner runs a command step and a plain user's is refused; plus a no-owner workflow is still refused.

Per creator on main:

Creator State
api/workflow.py execute verified caller, fixed here
api/templates.py _create_and_start_workflow already passes caller_id(current_user) (test added)
services/advanced_workflow/coordinator.py _create_workflow already passes owner_id; both routes pass caller_id (test added)
services/workflow_serializer.py import_workflow already passes owner_id; callers pass the verified user (test added)

No creator is an internal path without a person, so AC3 raises no decision.

Verification

  • creator_owner_20585_test.py: 5 passed.
  • Touched modules' tests, repo_tests/one_admin_gate_16333_test.py and the fast guards: 2103 passed, 2110 skipped.
  • Pre-commit hooks passed, including the Python file-size guard.

Model Used

Claude Sonnet 5.5

🤖 Generated with Claude Code

@mrveiss mrveiss added this to the M2 - Company OS workflow-ready milestone Nov 9, 2026
@mrveiss mrveiss added bug Something isn't working priority: medium backend phase:M2.4 Tasks and company workflows labels Nov 9, 2026
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 12f8e28 and 4764bdc.

Files selected for processing: 3

  • autobot-backend/api/workflow.py
  • autobot-backend/api/workflow_complex.py
  • autobot-backend/services/workflow_automation/creator_owner_20585_test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@mrveiss

mrveiss commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Review of the PR head for 21235.

Severity File:line Finding Fix
info autobot-backend/api/workflow_complex.py The move is not byte-identical, only identical apart from the issue's change: a new `owner_id: str None = Noneparameter and passing it tocreate_workflow_from_chat_request(..., owner_id=owner_id). The manager already accepts owner_id` (services/workflow_automation/manager.py:90). Body, error path, background task and return dict match the removed text.
none autobot-backend/api/workflow.py _execute_complex_workflow is imported into api.workflow, so api.workflow._execute_complex_workflow and the inspect.getsource checks in api_endpoint_migrations_test.py:5714-5731 still resolve. No other reference to the old location exists. The new module is wired by that import. workflow.py shrinks (1018 to 987 lines) and the new file is 57 lines. none
none autobot-backend/api/workflow.py (execute_workflow) owner_id=caller_id(current_user) where current_user comes from Depends(get_current_user), the authenticated principal, not the request body. caller_id is the shared helper in workflow_ownership.py. check_admin_permission already gates the route, so the two dependencies resolve the same user. none
low autobot-backend/services/workflow_automation/creator_owner_20585_test.py Tests drive the real execute_workflow and assert the admin runs and a non-admin is refused, with a no-owner control. The other three creators (template, coordinator, serializer) are tested the same way. Good coverage. none

This was referenced Nov 9, 2026
@mrveiss

mrveiss commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

Landed via merge train #21302 (merge commit 8b8d0b8) at dd90450; every commit on this branch is now on main.

@mrveiss mrveiss closed this Nov 11, 2026
@mrveiss mrveiss reopened this Nov 18, 2026
@mrveiss

mrveiss commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Branch audit (zero-change deletion). This PR shows 0 changed files against main (head 3f48f07c14): every change it carried is already in main. Closing and deleting the branch through this PR; it can be restored with the Restore branch button below.

@mrveiss mrveiss closed this Nov 18, 2026
@mrveiss
mrveiss deleted the issue-20585 branch November 18, 2026 08:53
This was referenced Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working phase:M2.4 Tasks and company workflows priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(workflow): four workflow creators record no owner or role, so their command steps are refused

1 participant