Skip to content

Query parameter parsing behavior#2

Draft
benchaplin wants to merge 1 commit intomainfrom
cursor/query-parameter-parsing-behavior-1118
Draft

Query parameter parsing behavior#2
benchaplin wants to merge 1 commit intomainfrom
cursor/query-parameter-parsing-behavior-1118

Conversation

@benchaplin
Copy link
Owner

  • Have you signed the contributor license agreement?
  • Have you followed the contributor guidelines?
  • If submitting code, have you built your formula locally prior to submission with gradle check?
  • If submitting code, is your pull request against main? Unless there is a good reason otherwise, we prefer pull requests against main and will backport as needed.
  • If submitting code, have you checked that your submission is for an OS and architecture that we support?
  • If you are submitting this code for a class then read our policy for that.

This PR introduces a new integration test suite, ClearIndicesCacheParametersIT, to investigate and confirm the query parameter parsing bug in the Clear Cache API (related to elastic#94512).

The tests demonstrate that the _cache/clear endpoint incorrectly interprets boolean query parameters (e.g., request=false or request not specified) as "clear all" due to a fallback mechanism in IndexService.clearCaches and IndicesService.clearIndexShardCache. This occurs because the system cannot distinguish between a parameter being explicitly set to false and it defaulting to false when not provided.

The 19 test methods cover various combinations of request, query, and fielddata parameters. All tests currently pass, asserting the existing (buggy) behavior. Specific test cases that highlight the bug are clearly marked with [BUG] in their assertion messages and Javadoc, making it straightforward to flip the assertions once a fix is implemented.


Open in Web Open in Cursor 

Add ClearIndicesCacheParametersIT to test and document the current
behavior of the clear cache API across all query parameter
combinations (request, query, fielddata).

Tests exercise the full REST flow via real HTTP requests and verify
which caches are actually cleared by checking index stats.

The tests document the bug from elastic#94512: when only request=true is
specified, all three caches are cleared instead of just the request
cache. This happens because IndexService.clearCaches() cannot
distinguish between 'not specified' (default false) and 'explicitly
set to false'.

Co-authored-by: Ben Chaplin <benchaplin@protonmail.com>
@cursor
Copy link

cursor bot commented Mar 6, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants