Skip to content

fix(runner): missing bundle/scenario returns 500 instead of the documented 400 #119

Description

@pparage

app/utils/checks_playbooks.py _resolve_file calls .resolve(strict=True) before any existence handling, so a missing playbook raises an uncaught FileNotFoundErrorHTTP 500, despite the docstring promising :raises HTTPException: 400 ... or the file does not exist.

POST /v0/admin/run/bundles/nonexistent_bundle/run  ->  500 Internal Server Error

Pre-existing, but #113 sharply increased the exposure: the hardcoded /core/* bundle routes are gone, so every bundle invocation now goes through the arbitrary {bundles_name:path} lookup, where a typo is the normal failure mode rather than an edge case. A 500 also gives the caller no way to distinguish "you named a bundle that doesn't exist" from "the server broke".

Fix: catch FileNotFoundError in _resolve_file and raise HTTPException(400) (or a Range42Error) with the resolved name, matching the format-validation failures alongside it.

Note tests/test_checks_playbooks.py::test_accepts_dotted_segment_format currently asserts pytest.raises(FileNotFoundError) — deliberately, since that is what makes the test non-vacuous today. It will need updating in lockstep with this fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions