Skip to content

Return 409 for PUT index when index exists#22354

Open
MdTanwer wants to merge 1 commit into
opensearch-project:mainfrom
MdTanwer:fix/put-index-conflict-409-20072
Open

Return 409 for PUT index when index exists#22354
MdTanwer wants to merge 1 commit into
opensearch-project:mainfrom
MdTanwer:fix/put-index-conflict-409-20072

Conversation

@MdTanwer

@MdTanwer MdTanwer commented Jun 30, 2026

Copy link
Copy Markdown

Summary

  • Return HTTP 409 (Conflict) instead of 400 when PUT <index> is called for an index that already exists
  • Map ResourceAlreadyExistsException to RestStatus.CONFLICT
  • Update related unit tests

Fixes #20072

@MdTanwer MdTanwer requested a review from a team as a code owner June 30, 2026 07:04
@github-actions github-actions Bot added bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing labels Jun 30, 2026
@MdTanwer MdTanwer force-pushed the fix/put-index-conflict-409-20072 branch 2 times, most recently from f9d55d3 to d378fb8 Compare June 30, 2026 07:04
PUT <index> returned HTTP 400 for resource_already_exists_exception.
Map ResourceAlreadyExistsException to RestStatus.CONFLICT (409).

Fixes opensearch-project#20072

Signed-off-by: MdTanwer <tanW9004167@gmail.com>
@MdTanwer MdTanwer force-pushed the fix/put-index-conflict-409-20072 branch from d378fb8 to 06c6e7e Compare June 30, 2026 07:05
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Behavior Change

Changing the HTTP status returned by ResourceAlreadyExistsException from 400 to 409 is a breaking API change. Any client code, integration tests, or downstream tooling that currently relies on receiving 400 for duplicate index creation (or other paths that throw this exception, e.g., index template/alias creation, snapshot restore) will see a different status code. While 409 is more semantically correct per the linked issue, this should be called out in release notes/breaking-changes documentation, and other test suites that assert 400 for these flows should be audited.

return RestStatus.CONFLICT;

@github-actions

Copy link
Copy Markdown
Contributor

✅ Gradle check result for 06c6e7e: SUCCESS

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.41%. Comparing base (319d78a) to head (06c6e7e).

Additional details and impacted files
@@            Coverage Diff            @@
##               main   #22354   +/-   ##
=========================================
  Coverage     73.40%   73.41%           
- Complexity    76075    76111   +36     
=========================================
  Files          6076     6076           
  Lines        345500   345500           
  Branches      49732    49732           
=========================================
+ Hits         253608   253638   +30     
+ Misses        71707    71635   -72     
- Partials      20185    20227   +42     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Put <index> returns 400 statuscode upon conflict instead of 409

1 participant