Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Nov 6, 2025

What is the problem this PR solves?

Handles a possible error in loading the model.Agent where the components field might be invalid JSON or a string (due to another bug). This changes the code to be more defensive, also should do less on parsing the components model when that is not needed.

How does this PR solve the problem?

Changes the components field to be a json.RawMessage that does two things. One it stops it from being parsed when the model.Agent is loaded from elasticsearch, which happens often and will reduce the time it takes to parse this field. Two, it stops that field from erroring to be unmarshalled when it is an invalid format.

How to test this PR locally

mage unitTest does a great job of covering it.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

Related issues

* Handle malformatted JSON in .fleet-agents components field.

* Add changelog.

* Add logs and update test to use require.

(cherry picked from commit f9dbe41)
@mergify mergify bot requested a review from a team as a code owner November 6, 2025 20:46
@mergify mergify bot added the backport label Nov 6, 2025
@mergify mergify bot requested review from blakerouse and michalpristas November 6, 2025 20:46
@prodsecmachine
Copy link

prodsecmachine commented Nov 6, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions github-actions bot added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Nov 6, 2025
@blakerouse blakerouse enabled auto-merge (squash) November 6, 2025 21:19
@blakerouse blakerouse merged commit bb3bdf3 into 9.2 Nov 6, 2025
12 checks passed
@blakerouse blakerouse deleted the mergify/bp/9.2/pr-5858 branch November 6, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants