Skip to content

Fix #37: path display in error message - #38

Open
BerengarWLehr wants to merge 1 commit into
camp-registry:mainfrom
BerengarWLehr:main
Open

Fix #37: path display in error message#38
BerengarWLehr wants to merge 1 commit into
camp-registry:mainfrom
BerengarWLehr:main

Conversation

@BerengarWLehr

@BerengarWLehr BerengarWLehr commented Aug 7, 2026

Copy link
Copy Markdown

Not sure how to upstream the fix into build directory, could not find correct build information.
Fixes #37

@BerengarWLehr BerengarWLehr changed the title Fix: path display in error message Fix #37: path display in error message Aug 7, 2026

@davidpesce davidpesce left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread camp/validate.py
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 "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
f"file is at {actual.name} under '{Path(*actual.parts[:-2])}/' but component "
f"file is at {actual.name} under '{actual.parent}/' but component "

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.

error running camp validate

2 participants