Skip to content

Conversation

Supplementing
Copy link
Contributor

Summary

Closes https://github.com/elastic/ingest-dev/issues/5992

  • Added error handling when an invalid sortField query field is passed to the GET api/fleet/agents endpoint. This error wrapping will handle other ES client errors and return the root cause as a 400 (bad request) response letting the user know what was wrong, instead of just returning a 500 error.
  • Also added additional test coverage to verify the handler will throw/succeed when its supposed to
image

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

@Supplementing Supplementing requested a review from a team as a code owner October 14, 2025 21:39
@Supplementing Supplementing added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:Fleet Team label for Observability Data Collection Fleet team labels Oct 14, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@Supplementing
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

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

I'm not loving this approach. it's extremely specific to this Fleet API & this type of ES error.

I can see from testing a direct ES query that this kind of error already returns 400 from ES. example curl:

curl -X GET -H "Content-Type: application/json" -d '{"sort":[{"invalid_field":{"order":"desc"}}]}' "http://elastic:changeme@localhost:9200/.kibana_ingest/_search" -v

can we explore a solution where the status code & error is just passed directly from ES? even better if we can handle it generically for all agent APIs (since they access ES directly instead of with soClient)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants