Skip to content

Commit

Permalink
[airbyte-cdk] - Update JSON Error Message Parser to return additional…
Browse files Browse the repository at this point in the history
… error message fields or default to dict (#44010)
  • Loading branch information
pnilan authored Aug 28, 2024
1 parent af98a81 commit 1060161
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
from typing import Optional

import requests
from airbyte_cdk.sources.streams.http.error_handlers import ErrorMessageParser
from airbyte_cdk.sources.utils.types import JsonType

from .error_message_parser import ErrorMessageParser


class JsonErrorMessageParser(ErrorMessageParser):
def _try_get_error(self, value: Optional[JsonType]) -> Optional[str]:
Expand All @@ -26,6 +25,11 @@ def _try_get_error(self, value: Optional[JsonType]) -> Optional[str]:
or value.get("failures")
or value.get("failure")
or value.get("detail")
or value.get("err")
or value.get("error_message")
or value.get("msg")
or value.get("reason")
or value.get("status_message")
)
return self._try_get_error(new_value)
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
(b'{"message": "json error message"}', "json error message"),
(b'[{"message": "list error message"}]', "list error message"),
(b'[{"message": "list error message 1"}, {"message": "list error message 2"}]', "list error message 1, list error message 2"),
(b'{"error": "messages error message"}', "messages error message"),
(b'[{"errors": "list error message 1"}, {"errors": "list error message 2"}]', "list error message 1, list error message 2"),
(b'{"failures": "failures error message"}', "failures error message"),
(b'{"failure": "failure error message"}', "failure error message"),
(b'{"detail": "detail error message"}', "detail error message"),
(b'{"err": "err error message"}', "err error message"),
(b'{"error_message": "error_message error message"}', "error_message error message"),
(b'{"msg": "msg error message"}', "msg error message"),
(b'{"reason": "reason error message"}', "reason error message"),
(b'{"status_message": "status_message error message"}', "status_message error message"),
]
)
Expand Down

0 comments on commit 1060161

Please sign in to comment.