Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[confmap] Add error hint when invalid YAML was passed #12180

Merged
merged 4 commits into from
Feb 25, 2025

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Jan 24, 2025

Description

Add error hint field to surface YAML parsing errors. This only surfaces the error for top-level URIs but it's a step in the right direction.

Error when passing a file with contents [invalid:, as the config:

Before:

retrieved value (type=string) cannot be used as a Conf

After:

retrieved value (type=string) cannot be used as a Conf: assuming string type since contents are not valid YAML: yaml: line 1: did not find expected node content

Link to tracking issue

Updates #12000

Testing

Documentation

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.19%. Comparing base (7c1d694) to head (339c042).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12180   +/-   ##
=======================================
  Coverage   92.19%   92.19%           
=======================================
  Files         465      465           
  Lines       25194    25204   +10     
=======================================
+ Hits        23228    23238   +10     
  Misses       1570     1570           
  Partials      396      396           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mattsains
Copy link
Contributor

mattsains commented Jan 24, 2025

One thing I noticed a lot while researching this issue is that a lot of the test cases only test that some kind of error was produced, and not the content of the error. Perhaps you could consider fixing that as part of this PR. Examples:

Improving these tests would prevent a regression like this in the future, they're easy to find by searching for require.Error and easy to fix by changing them to require.EqualError(t, err, "expected message"). You can even just run the tests with the expected message set to blank and figure out what the expected error is.

@mx-psi
Copy link
Member Author

mx-psi commented Jan 27, 2025

@mattsains That makes sense. I am not going to work on this further at least until next week, if you want to file a PR adding the EqualErrors or continue on top of this branch feel free to do so!

@mx-psi mx-psi marked this pull request as ready for review February 4, 2025 13:30
@mx-psi mx-psi requested review from evan-bradley and a team as code owners February 4, 2025 13:30
@mx-psi
Copy link
Member Author

mx-psi commented Feb 4, 2025

@mattsains Can you take another look?

Copy link
Contributor

@mattsains mattsains left a comment

Choose a reason for hiding this comment

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

looks good to me! Although I'm not a maintainer on this repo

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2025
@mattsains
Copy link
Contributor

Not stale, needs approver

@mx-psi
Copy link
Member Author

mx-psi commented Feb 25, 2025

cc @open-telemetry/collector-approvers PTAL!

@mx-psi mx-psi added this pull request to the merge queue Feb 25, 2025
Merged via the queue into open-telemetry:main with commit e7f071d Feb 25, 2025
55 checks passed
@mx-psi mx-psi deleted the mx-psi/error-map branch February 25, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants