Skip to content

[Jamie] Wrap Stakwork /projects payload under project key so webhook_full_output survives - #5224

Merged
gonzaloaune merged 3 commits into
masterfrom
swarm/swarm-change-cfeb8891
Sep 2, 2026
Merged

[Jamie] Wrap Stakwork /projects payload under project key so webhook_full_output survives#5224
gonzaloaune merged 3 commits into
masterfrom
swarm/swarm-change-cfeb8891

Conversation

@gonzaloaune

Copy link
Copy Markdown
Collaborator

Problem

For plan_mode / workflow_editor runs, callStakworkAPI sets webhook_full_output: false as a top-level key in the Stakwork /projects request body. But Stakwork stores webhook_full_output: true anyway.

Root cause

Hive sends a flat JSON body (no { project: ... } envelope). Stakwork's ProjectsController relies on Rails wrap_parameters (format: [:json], no explicit include), which wraps only real Project DB columns into params[:project]. webhook_full_output (like stop_on_errors and debug_mode) is NOT a column — it lives inside the project_configs JSON blob — so the wrapper drops it. Strong params then see nil, and create_project defaults it back to true.

If the body is sent pre-nested under project, Rails uses the explicit nested key as-is and the drop does not happen.

Fix

Wrap the outbound payload as { project: stakworkPayload } in callStakworkAPI so webhook_full_output (and the other non-column config keys) are correctly nested. Sending a body that already has a project root key is safe: wrap_parameters only adds a synthetic copy, it never alters an already-present project key.

…k_full_output survives

## Problem

For plan_mode / workflow_editor runs, `callStakworkAPI` sets `webhook_full_output: false` as a top-level key in the Stakwork `/projects` request body. But Stakwork stores `webhook_full_output: true` anyway.

## Root cause

Hive sends a **flat** JSON body (no `{ project: ... }` envelope). Stakwork's `ProjectsController` relies on Rails `wrap_parameters` (`format: [:json]`, no explicit `include`), which wraps **only real `Project` DB columns** into `params[:project]`. `webhook_full_output` (like `stop_on_errors` and `debug_mode`) is NOT a column — it lives inside the `project_configs` JSON blob — so the wrapper drops it. Strong params then see `nil`, and `create_project` defaults it back to `true`.

If the body is sent pre-nested under `project`, Rails uses the explicit nested key as-is and the drop does not happen.

## Fix

Wrap the outbound payload as `{ project: stakworkPayload }` in `callStakworkAPI` so `webhook_full_output` (and the other non-column config keys) are correctly nested. Sending a body that already has a `project` root key is safe: `wrap_parameters` only *adds* a synthetic copy, it never alters an already-present `project` key.
callStakworkAPI now wraps the outbound Stakwork /projects request body
as { project: stakworkPayload } (see previous commit). Unit tests were
still parsing the fetch body and reading fields (workflow_id,
webhook_url, workflow_params, name, etc.) directly off the top level,
so they broke once the envelope was introduced.

Update all affected test files to unwrap the parsed body when it has a
top-level `project` key before asserting on its contents:

- src/__tests__/unit/services/task-workflow.test.ts
- src/__tests__/unit/api/chat/call-stakwork.test.ts
- src/__tests__/unit/api/chat/message/call-stakwork.test.ts
- src/__tests__/unit/api/chat/message/route.test.ts
- src/__tests__/unit/api/api-chat-message.test.ts
- src/__tests__/unit/services/call-stakwork-api.test.ts
- src/__tests__/unit/services/task-workflow-createChatMessageAndTriggerStakwork.test.ts
@gonzaloaune
gonzaloaune enabled auto-merge (squash) September 2, 2026 13:48
@gonzaloaune
gonzaloaune merged commit f14d1a3 into master Sep 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jamie Automated PR opened by Jamie

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants