Skip to content

Include base error for json decode error responses#5069

Merged
michel-laterman merged 6 commits intoelastic:mainfrom
michel-laterman:json-decode-err-details
Jul 3, 2025
Merged

Include base error for json decode error responses#5069
michel-laterman merged 6 commits intoelastic:mainfrom
michel-laterman:json-decode-err-details

Conversation

@michel-laterman
Copy link
Contributor

What is the problem this PR solves?

There is no information on why request bodies fail to decode as JSON

How does this PR solve the problem?

Include the base json decode error as part of the response.

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

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
@michel-laterman michel-laterman requested a review from a team as a code owner June 26, 2025 21:08
@michel-laterman michel-laterman added the bug Something isn't working label Jun 26, 2025
@michel-laterman michel-laterman added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-active-all Automated backport with mergify to all the active branches labels Jun 26, 2025
@prodsecmachine
Copy link

prodsecmachine commented Jun 26, 2025

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

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

cmacknz
cmacknz previously approved these changes Jun 26, 2025
Copy link
Member

@cmacknz cmacknz left a comment

Choose a reason for hiding this comment

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

Thanks, doing a quick paranoia check I don't see any places where nextErr could contain anything we wouldn't want to give back to a client: https://github.com/search?q=repo%3Aelastic%2Ffleet-server%20nextErr&type=code

Copy link
Contributor

@pkoutsovasilis pkoutsovasilis left a comment

Choose a reason for hiding this comment

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

The code changes look good to me, but could you please update the unit-tests to have a green CI @michel-laterman ? 🙂

@michel-laterman
Copy link
Contributor Author

Current e2e failure is dues to the version bump, the test needs elastic-agent-9.2.0-SNAPSHOT-linux-x86_64.tar.gz but can't find it

@michel-laterman
Copy link
Contributor Author

buildkite test this

@michel-laterman michel-laterman merged commit 966c4f8 into elastic:main Jul 3, 2025
8 of 9 checks passed
@michel-laterman michel-laterman deleted the json-decode-err-details branch July 3, 2025 16:28
@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2025

@Mergifyio backport 8.17 8.18 8.19 9.0 9.1

@mergify
Copy link
Contributor

mergify bot commented Jul 3, 2025

backport 8.17 8.18 8.19 9.0 9.1

✅ Backports have been created

Details
mergify bot pushed a commit that referenced this pull request Jul 3, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)

# Conflicts:
#	internal/pkg/api/handleEnroll_test.go
mergify bot pushed a commit that referenced this pull request Jul 3, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)
mergify bot pushed a commit that referenced this pull request Jul 3, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)

# Conflicts:
#	internal/pkg/api/handleEnroll_test.go
mergify bot pushed a commit that referenced this pull request Jul 3, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)
mergify bot pushed a commit that referenced this pull request Jul 3, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)
michel-laterman added a commit that referenced this pull request Jul 4, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
michel-laterman added a commit that referenced this pull request Jul 4, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
michel-laterman added a commit that referenced this pull request Jul 4, 2025
* Include base error for json decode error responses

(cherry picked from commit 966c4f8)

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
michel-laterman added a commit that referenced this pull request Jul 4, 2025
…nses (#5085)

* Include base error for json decode error responses (#5069)

* Include base error for json decode error responses

(cherry picked from commit 966c4f8)

# Conflicts:
#	internal/pkg/api/handleEnroll_test.go

* Fix backport

---------

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
michel-laterman added a commit that referenced this pull request Jul 4, 2025
…nses (#5083)

* Include base error for json decode error responses (#5069)

* Include base error for json decode error responses

(cherry picked from commit 966c4f8)

# Conflicts:
#	internal/pkg/api/handleEnroll_test.go

* Fix backport

* remove FIPS unit test

---------

Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Co-authored-by: michel-laterman <michel.laterman@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

4 participants