Fix #37: path display in error message - #38
Conversation
davidpesce
left a comment
There was a problem hiding this comment.
Thanks for the report and the fix, both confirmed. The crash reproduces exactly as described: validating a bare filename enters the misplacement branch and parts[-2] is out of range.
One inline suggestion on the message text below.
A regression test would be welcome alongside (tests/test_registry.py holds the validate cases; a bare-filename validate asserting a problem string rather than a traceback). If you'd rather not, we can add it when this lands.
One unrelated note since your example entry shows it: as of camp-tools v0.2.51, security-contact: empty fails schema validation. The field needs an email address or an http(s) URL.
| if actual.parts[-2:] != expected_rel.parts: | ||
| problems.append( | ||
| f"file is at {actual.name} under '{actual.parts[-2]}/' but component " | ||
| f"file is at {actual.name} under '{Path(*actual.parts[:-2])}/' but component " |
There was a problem hiding this comment.
Path(*actual.parts[:-2]) drops the directory the message exists to name. For plugins/wrongdir/local_x.yml it prints "under 'plugins/'", but the reader needs to see wrongdir. actual.parent handles every case: . for a bare filename, the real directory otherwise.
| f"file is at {actual.name} under '{Path(*actual.parts[:-2])}/' but component " | |
| f"file is at {actual.name} under '{actual.parent}/' but component " |
Not sure how to upstream the fix into build directory, could not find correct build information.
Fixes #37