Repository navigation
fix(es-compat): accept PUT on /_bulk and /{index}/_bulk (#3036) - #3037
Merged
Merged
Conversation
Why: Elasticsearch 8.x takes both POST and PUT on the two bulk paths (rest-api-spec bulk.json), and the official Python client 8.x sends PUT from helpers.bulk. XERJ registered POST only, so that client got 405 Method Not Allowed and wrote nothing. Found while capturing the home page's Elasticsearch bridge picture with elasticsearch-py 8.19.3 against the rc.101 release. Before: PUT /_bulk and PUT /t/_bulk -> 405. After: both -> 200, errors=false, the document is readable. Fix: engine/crates/xerj-api/src/router.rs registers .put() next to .post() on both routes, same handlers. Authorization did not need a change: authz::body_shape classifies any _bulk path as BodyShape::Bulk regardless of method, and required_privilege maps a non-GET _bulk op to WriteIndex, so PUT gets the same per-action-line index checks as POST. Guests stay refused (PUT is not a guest read verb). The authz unit tests now pin that: body_shape_table has the PUT rows, and the reserved-namespace test checks that a PUT bulk cannot forge or delete in another principal's brain and still works inside its own grant. Tests: new engine/crates/xerj-api/tests/bulk_accepts_put.rs (PUT global, PUT per-index, POST unchanged). Without the router change the two PUT tests fail with 405; with it all 3 pass. authz::tests 30 passed. Reference-coding skipped: a two-line route registration in our own router.
gonzalolater
approved these changes
Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3036.
Elasticsearch 8.x takes POST and PUT on the bulk paths, and elasticsearch-py 8.x
helpers.bulksends PUT. XERJ answered 405.router.rs:.put()next to.post()on/_bulkand/:index/_bulk, same handlers._bulkalready (body_shape->Bulk, non-GET ->WriteIndex); the authz unit tests now pin PUT for the forge/delete/own-grant cases.tests/bulk_accepts_put.rs: PUT global, PUT per-index, POST unchanged. The two PUT tests fail with 405 without the router change.Local:
cargo test -p xerj-api --test bulk_accepts_put3 passed;authz::tests30 passed. The ES-YAML gate runs in CI.After this ships in a release, the home page block 07 can drop its PUT sentence (PR #3034).
🤖 Generated with Claude Code