-
Notifications
You must be signed in to change notification settings - Fork 146
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
Add custom MarshalYAML() method to component to fix YAML marshaling of error values #3835
Add custom MarshalYAML() method to component to fix YAML marshaling of error values #3835
Conversation
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
This pull request does not have a backport label. Could you fix it @fearful-symmetry? 🙏
NOTE: |
…or-marshal-componet
SonarQube Quality Gate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Thanks for the improvement!
@fearful-symmetry What would you think about backporting this to 8.11 branch? |
Good idea, added the backport label |
…f error values (#3835) * add custom MarshalYAML to component * add changelog * add nil check * update tests --------- Co-authored-by: Pierre HILBERT <[email protected]> (cherry picked from commit 93f159a)
…f error values (#3835) (#3856) * add custom MarshalYAML to component * add changelog * add nil check * update tests --------- Co-authored-by: Pierre HILBERT <[email protected]> (cherry picked from commit 93f159a) Co-authored-by: Alex K <[email protected]> Co-authored-by: Pierre HILBERT <[email protected]>
What does this PR do?
fixes #2940
This adds a
MarshalYAML()
method to theComponent
type that populates anErrMsg
value. This is needed to properly report any potential error values that might end up in a diagnostic dump; depending on the underlying type that's in theErr
field, the YAML marshaller might just end up creating an empty{}
value in the final YAML. I figured this approach, of creating a specialErrMsg
field, was less invasive than coming up with some custom error wrapper that we would need to give special treatment.Why is it important?
Errors should be properly reported in diagnostic dumps
Checklist
- [ ] I have made corresponding changes to the documentation- [] I have made corresponding change to the default configuration files./changelog/fragments
using the changelog tool