fix(cli): report malformed policy files cleanly - #129
Conversation
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
rng1995
left a comment
There was a problem hiding this comment.
The policy loader now consistently normalizes malformed YAML, invalid UTF-8, parser recursion failures, and read errors while preserving FileNotFoundError behavior and exception causes. I verified concise path-specific CLI failures, 57 focused policy/CLI/golden tests, Ruff, diff checks, and green CI. The implementation looks good. GitHub currently reports a CHANGELOG.md conflict with main; that must still be resolved and the resulting head should complete CI before merge.
|
@rioyu123 - Please resolve merge conflicts. |
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
Thanks for the review. I've merged main ( With the locked dependencies on Linux, the 57 focused tests, lint, and package build pass. The full suite reports 6,008 passed, 51 skipped, and 5 failures; all five also reproduce on unmodified main on this machine (two runtime-discovery tests, an occupied-port test, and two HTML-parser cases). I've left those outside this PR. The updated head still needs hosted CI to pass before merging. |
|
Please fix the CI Test that is failing @rioyu123 |
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
Thanks for flagging this. The test's 50 ms header timeout was still active for the final health check, and it relied on a fixed sleep for earlier connections to finish. It now waits for those connections and workers to finish, then restores the normal timeout before checking health. Bridge production timeouts and the worker limit are unchanged. On Python 3.13.15, a controlled 150 ms delay before parsing the health request makes both pre-merge main and the previous PR head fail on that same final health request; the updated test passes that probe and 20 normal repetitions. Disabling header expiry still makes the updated test fail. The updated test also passes that probe on Python 3.12. I also merged current main ( |
Summary
Malformed, non-UTF-8, deeply nested, or unreadable bundled and custom policy files now follow a path-specific error contract. The CLI converts those failures into concise Click errors instead of exposing raw parser, decoder, recursion, or I/O exceptions.
The change uses one private loader helper for both policy paths, preserves the original exception as the cause, keeps
FileNotFoundErrorbehavior unchanged, and does not fall back to a default policy after an explicit invalid--policyinput.Fixes #128.
Verification
Focused verification:
\\tmp\\runversus/tmp/run)Release Impact