Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bulk api silently ignores unknown operations #5299

Closed
adnapibar opened this issue Nov 17, 2022 · 4 comments · Fixed by #5302
Closed

[BUG] Bulk api silently ignores unknown operations #5299

adnapibar opened this issue Nov 17, 2022 · 4 comments · Fixed by #5302
Assignees
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Comments

@adnapibar
Copy link
Contributor

Describe the bug

The bulk api supports the following actions: create, delete, index, update. However, if the request contains an invalid operation then it silently ignores it.

To Reproduce

Given the following bulk request

{ "create" : { "_index" : "foo", "_id" : "1" } }
{ "id": "1", "field1" : "value1"}
{ "remove" : { "_index" : "foo", "_id" : "2" } }
{ "id": "2", "field1" : "value2"}

The _bulk api successfully returns

{
    "took": 1366,
    "errors": false,
    "items": [
        {
            "create": {
                "_index": "foo",
                "_id": "1",
                "_version": 1,
                "result": "created",
                "_shards": {
                    "total": 2,
                    "successful": 1,
                    "failed": 0
                },
                "_seq_no": 0,
                "_primary_term": 1,
                "status": 201
            }
        }
    ]
}

Expected behavior
The api call should fail resulting in a proper error message, something like

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Unknown action line [3], expected one of [create, delete, index, update] but found [remove]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Unknown action line [3], expected one of [create, delete, index, update] but found [remove]"
    },
    "status": 400
}

Host/Environment (please complete the following information):

  • OS: macOS
  • Version 12.6.1

Additional context
None

@adnapibar adnapibar added bug Something isn't working untriaged Indexing Indexing, Bulk Indexing and anything related to indexing labels Nov 17, 2022
@adnapibar adnapibar self-assigned this Nov 17, 2022
@andrross
Copy link
Member

The API will report partial failures in other cases. This appears to fail the entire request in one item has an invalid action. Why the difference?

@adnapibar
Copy link
Contributor Author

The API will report partial failures in other cases. This appears to fail the entire request in one item has an invalid action. Why the difference?

This is invalid request, I don't think we should be processing this request at all. Partial failures happen for valid requests during indexing time.

@andrross
Copy link
Member

What's the behavior if there is a line of malformed JSON or if a line omits the action all together? I think I agree that invalid requests should be rejected completely, but we should be consistent for all invalid cases.

@adnapibar
Copy link
Contributor Author

What's the behavior if there is a line of malformed JSON or if a line omits the action all together? I think I agree that invalid requests should be rejected completely, but we should be consistent for all invalid cases.

It rejects the request - https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/action/bulk/BulkRequestParser.java#L155-L273

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 a pull request may close this issue.

2 participants