Add retryable GET assertions and JSONPath-based expected response extraction by YoEight · Pull Request #6266 · meilisearch/meilisearch · GitHub
Skip to content

Add retryable GET assertions and JSONPath-based expected response extraction#6266

Open
YoEight wants to merge 1 commit intomainfrom
xtask-expect-improve
Open

Add retryable GET assertions and JSONPath-based expected response extraction#6266
YoEight wants to merge 1 commit intomainfrom
xtask-expect-improve

Conversation

@YoEight
Copy link
Copy Markdown
Member

@YoEight YoEight commented Mar 19, 2026

This PR improves xtask workload command validation by adding retryable GET assertions and JSONPath-based response extraction for expected_response checks. When working on #6193, The first implementation was much easier to test with those changes in xtasks. We changed direction later on but I think it can stil be useful for writing workloads tests.

What changed

  • added a retryFor field to workload commands so GET requests can be retried for a bounded duration when the response does not yet match the expected payload
  • added $extractor support in expectedResponse so workloads can assert against a JSONPath-selected subset of the server response

when retryFor is set and the command is a GET, we now wait for 500ms between new attempt. Using retryFor with any method but a GET is just ignored and default to the existing behavior. Also, retryFor won't retry when the expected status doesn't match. It might sound counter-intuitive but the feature was initially added to retry when only the content of successful request didn't match. Nothing prevents us from retrying in that specific case though.

As the spec demands, querying with jsonpath always returns an array. To improve the ergonomics, I inspect the expectedValue property and promote any value to an array unless it's already an array of course. This feature is really useful when what you need to expect is nested deep into an object and using our placeholder syntax is not possible.

Worth noting that the extractor feature doesn't work well with --update-response. If you do use that flag, it will just overwrite the expectedResponse with the full response, not the extracted part. That means the extractor feature doesn't play nice with register either. I believe if you need the extraction feature, you shouldn't need --update-response or register.

I tried to find an existing workload to "prove" that feature works but I didn't find any suitable candidate.

Command example

{
  "route": "/indexes",
  "method": "GET",
  "retryFor": "10s",
  "expectedStatus": 200,
  "expectedResponse": {
    "$extractor": {
      "path": "$.results[*].uid",
      "expectedValue": ["movies"]
    }
  }
}

Generative AI tools

  • This PR does not use generative AI tooling
  • This PR uses generative AI tooling and respect the related policies
    • list of used tools and what they were used for

@YoEight YoEight added the no db change The database didn't change label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no db change The database didn't change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant