Repository navigation
paths: name the attribute in resolution errors, accept scalar additional contexts - #971
Merged
Merged
Conversation
A value that is not a path was reported as "unexpected type int", leaving the user to look for the number in the whole document. The error is now prefixed once, where the tree is walked, with the path of the attribute, as the errors of the other steps of the loading are. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
…oolean The schema accepts a number, a boolean or null as the value of a mapping of additional contexts, and the model reads them as text, but the resolution of paths rejected them. They are now resolved like the text they are written with, as in the list form. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in the focused implementation and regression coverage; tests were not executed.
No open issues 🎉
What changed in this PR
This PR improves Compose path-resolution errors by naming the affected attribute and makes scalar additional build contexts load consistently with their list-form equivalents.
Changes:
- Prefix resolver errors with attribute paths while preserving wrapped errors.
- Convert numeric and boolean additional contexts to strings, leaving null values unchanged.
- Add regression coverage and update the expected bind-mount error.
| File | Description |
|---|---|
paths/resolve.go |
Adds attribute-aware error wrapping and routes additional contexts to their dedicated resolver. |
paths/resolve_test.go |
Tests scalar contexts and attribute paths in errors. |
paths/context.go |
Adds scalar conversion for additional build contexts. |
loader/tests/build_test.go |
Adds loader coverage for scalar contexts and contextual errors. |
loader/loader_test.go |
Updates the expected bind-mount error text. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does, in one sentence
An error raised while resolving the paths of a project now names the attribute it comes from, and an additional build context written as a number no longer fails at all.
Context
When a value cannot be read as a path, the user gets a bare message that says nothing of where it comes from:
while every other step of the loading names the attribute (
services[foo].secrets[0].mode ...). The same goes for a bind mount without a source, which did not even name the service.One case is reachable with the schema validation too:
additional_contextsis alist_or_dict, so the schema accepts a number or a boolean as the value of a mapping entry, and the model reads it as text.additional_contexts: {a: 1}was rejected with the bareunexpected type int, whileadditional_contexts: [a=1]loads.What the PR brings
services.foo.build.context: unexpected type int,services.foo.volumes.[]: invalid mount config for type "bind": field Source must not be empty. The entries of a list are written[], as in the errors of the transformations. The wrapped error is still available toerrors.Is/As.a: 1gives<working dir>/1); a null one is left as it is, likebuild.ssh.🤖 Generated with Claude Code