Skip to content

Fix missing workflow 404 handling and add regression tests#326

Merged
pradeeban merged 2 commits intoControlCore-Project:devfrom
Titas-Ghosh:fix/workflow-404-missing-id
Feb 20, 2026
Merged

Fix missing workflow 404 handling and add regression tests#326
pradeeban merged 2 commits intoControlCore-Project:devfrom
Titas-Ghosh:fix/workflow-404-missing-id

Conversation

@Titas-Ghosh
Copy link

Fixes #323

Problem

GET /workflow/<serverID> could miss the intended 404 Not Found path because model and controller used different not-found contracts:

  • WorkFlowModel.get() could return (False, 'Record Not Found')
  • getWorkflow() checked only for None

This mismatch could lead to invalid downstream behavior instead of a clean 404.

Root Cause

Inconsistent API contract between:

  • server/model/workflows.py
  • server/controller/workflow.py

Changes

  1. Standardized model contract:
  • WorkFlowModel.get() now returns None when serverID is missing.
  1. Hardened controller handling:
  • Added isMissingWorkflow(...) guard in server/controller/workflow.py.
  • Guard handles both:
    • new contract: None
    • legacy contract: (False, 'Record Not Found')
  • Ensures GET /workflow/<serverID> consistently returns 404 for missing workflows.
  1. Added regression tests:
  • New file: server/tests/test_workflow_controller.py
  • Covers:
    • missing workflow (None) -> 404
    • missing workflow (legacy tuple) -> 404
    • hash mismatch with X-Latest-Hash -> 400
    • hash match with X-Latest-Hash -> 200

Files Changed

  • server/model/workflows.py
  • server/controller/workflow.py
  • server/tests/test_workflow_controller.py

Behavior After This PR

  • GET /workflow/<missing-id> always returns 404 Not Found
  • Behavior is consistent with and without X-Latest-Hash
  • Legacy not-found return shape is still safely handled in controller

Validation

  • Syntax check passed:
    • python -m py_compile server/controller/workflow.py server/model/workflows.py server/tests/test_workflow_controller.py
  • Ran backend regression tests locally(from server/):
    • python -m unittest discover -s tests -p "test_*.py" -v
  • Result: Ran 4 tests ... OK

Test Output Screenshot

Screenshot 2026-02-20 032147

Notes

This is backward-compatible at controller level while moving model behavior to a single clear not-found contract.

@pradeeban pradeeban merged commit 6afd11b into ControlCore-Project:dev Feb 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants