[Jamie] Wrap Stakwork /projects payload under project key so webhook_full_output survives - #5224
Merged
Merged
Conversation
…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
enabled auto-merge (squash)
September 2, 2026 13:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
For plan_mode / workflow_editor runs,
callStakworkAPIsetswebhook_full_output: falseas a top-level key in the Stakwork/projectsrequest body. But Stakwork storeswebhook_full_output: trueanyway.Root cause
Hive sends a flat JSON body (no
{ project: ... }envelope). Stakwork'sProjectsControllerrelies on Railswrap_parameters(format: [:json], no explicitinclude), which wraps only realProjectDB columns intoparams[:project].webhook_full_output(likestop_on_errorsanddebug_mode) is NOT a column — it lives inside theproject_configsJSON blob — so the wrapper drops it. Strong params then seenil, andcreate_projectdefaults it back totrue.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 }incallStakworkAPIsowebhook_full_output(and the other non-column config keys) are correctly nested. Sending a body that already has aprojectroot key is safe:wrap_parametersonly adds a synthetic copy, it never alters an already-presentprojectkey.