Skip to content

fix(workflows): sync workflow_raw YAML when toggling disabled state (fixes #5361)#6227

Open
asheesh-devops wants to merge 1 commit intokeephq:mainfrom
asheesh-devops:fix/5361-workflow-disabled-yaml-sync
Open

fix(workflows): sync workflow_raw YAML when toggling disabled state (fixes #5361)#6227
asheesh-devops wants to merge 1 commit intokeephq:mainfrom
asheesh-devops:fix/5361-workflow-disabled-yaml-sync

Conversation

@asheesh-devops
Copy link
Copy Markdown

Summary

Fixes mismatch between the workflow card's "Disabled" label and the actual YAML disabled field when toggling a workflow's enabled/disabled state via the API.

Root Cause

In toggle_workflow_state(), only the is_disabled DB column was updated — the raw YAML stored in workflow_raw was never touched. This caused the UI card to show one state while the YAML contained a different disabled value. There was already a TODO comment acknowledging this:

# Toggle the disabled state
# TODO: update workflow_raw
workflow.is_disabled = not workflow.is_disabled

The Fix

Parse the stored YAML, update the disabled key to match the new state, and write it back:

# Before (broken):
workflow.is_disabled = not workflow.is_disabled
# workflow_raw still has the old "disabled" value

# After (fixed):
workflow.is_disabled = not workflow.is_disabled
workflow_raw_data = cyaml.safe_load(workflow.workflow_raw)
workflow_raw_data["disabled"] = workflow.is_disabled
workflow.workflow_raw = cyaml.dump(workflow_raw_data, width=99999)

This follows the same cyaml.dump(data, width=99999) pattern used in the workflow update endpoint (line 848).

Changes

  • keep/api/routes/workflows.py — sync workflow_raw YAML in toggle_workflow_state()

Testing

  • Verified cyaml.safe_load / cyaml.dump are used throughout the codebase for YAML serialization
  • The update workflow endpoint already reads disabled from YAML via workflow_raw_data.get("disabled", False) — this fix ensures round-trip consistency
  • The width=99999 parameter matches existing usage to prevent unwanted line wrapping

Fixes #5361

…ixes keephq#5361)

Update the toggle endpoint to also update the 'disabled' key in the
stored workflow_raw YAML, keeping the DB field and YAML in sync.
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. Bug Something isn't working labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Mismatch between WF card and Yaml contain

1 participant