Skip to content

Error management on data integrity errors #2467

Closed
@anton-johansson

Description

@anton-johansson

I'm trying to do atomic updates, utilizing the _version (@Version) field. I'm trying to properly handle 409 Conflict, and I see that we get a DataAccessResourceFailureException that only has a message:

method [PUT], host [http://localhost:9200], URI [/my-index/_doc/abc123?refresh=false&version_type=external&version=3], status line [HTTP/1.1 409 Conflict]
{"error":{"root_cause":[{"type":"version_conflict_engine_exception","reason":"[abc123]: version conflict, current version [4] is higher or equal to the one provided [3]","index_uuid":"czrIO6l-Tl-A4qvlM27RyA","shard":"0","index":"my-index"}],"typ
e":"version_conflict_engine_exception","reason":"[abc123]: version conflict, current version [4] is higher or equal to the one provided [3]","index_uuid":"czrIO6l-Tl-A4qvlM27RyA","shard":"0","index":"my-index"},"status":409}

This is really hard to work with. Could we not extend DataAccessResourceFailureException (maybe ElasticsearchResourceFailureException?) that has more information about the failure?

catch (ElasticsearchResourceFailureException e) {
    System.out.println(e.getStatusCode());
    System.out.println(e.getResponseBody());
    System.out.println(e.getError()); // <- could be a parsed Error object or a Map<String, Object>?
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions