Skip to content

Conversation

@denik
Copy link
Contributor

@denik denik commented Apr 23, 2025

Changes

Add prefixes with context for errors in target override.

Why

Saw an error that looks like

Error: invalid path '.'

The error was caused by some other breaking changes, so I don't have a test, but still, if users ever see that it's not very helpful (e.g. path does not refer to file system but it is related to dyn.Value).

Tests

Existing tests.

} {
if root, err = mergeField(root, target, f); err != nil {
return err
return fmt.Errorf("failed to merge target=%s field=%s: %w", name, f, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this and above error remain uncovered, I don't know an easy way to trigger it, but it is still worth having context in the error IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it is unreachable code because the configuration is normalized before merging. That means the types match up and merging cannot fail. Still good to include the context in case this assumption changes.

} {
if root, err = mergeField(root, target, f); err != nil {
return err
return fmt.Errorf("failed to merge target=%s field=%s: %w", name, f, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it is unreachable code because the configuration is normalized before merging. That means the types match up and merging cannot fail. Still good to include the context in case this assumption changes.

@denik denik added this pull request to the merge queue Apr 24, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 24, 2025
@denik denik temporarily deployed to test-trigger-is April 24, 2025 08:30 — with GitHub Actions Inactive
@denik denik enabled auto-merge April 24, 2025 08:30
@denik denik disabled auto-merge April 24, 2025 08:42
@denik denik merged commit bac7b49 into main Apr 24, 2025
9 of 10 checks passed
@denik denik deleted the denik/better-error branch April 24, 2025 08:42
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.

3 participants