8000 fix(es-compat): accept PUT on /_bulk and /{index}/_bulk (#3036) by xerj-org · Pull Request #3037 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(es-compat): accept PUT on /_bulk and /{index}/_bulk (#3036) - #3037

Merged
xerj-org merged 1 commit into
mainfrom
fix/3036-bulk-put
Nov 8, 2026
Merged

xerj-org merged 1 commit into
mainfrom
fix/3036-bulk-put

Conversation

@xerj-org
@xerj-org xerj-org commented Nov 7, 2026
Copy link
Copy Markdown
Owner

Fixes #3036.

Elasticsearch 8.x takes POST and PUT on the bulk paths, and elasticsearch-py 8.x helpers.bulk sends PUT. XERJ answered 405.

  • router.rs: .put() next to .post() on /_bulk and /:index/_bulk, same handlers.
  • Authorization is method-independent for _bulk already (body_shape -> Bulk, non-GET -> WriteIndex); the authz unit tests now pin PUT for the forge/delete/own-grant cases.
  • New 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_put 3 passed; authz::tests 30 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

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.
@cla-bot cla-bot Bot added the cla-signed label Nov 7, 2026
@xerj-org
xerj-org merged commit f73bbd9 into main Nov 8, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES bridge: PUT /_bulk and PUT /{index}/_bulk answer 405 (Python helpers.bulk fails)

2 participants

0