Search before asking
Paimon version
master (1d368b4)
Compute Engine
PyPaimon REST client. Engine-independent.
Minimal reproduce step
from pypaimon.api.client import _parse_error_response, DefaultErrorHandler
error = _parse_error_response(
'{"message":"missing",'
'"resourceType":"TABLE",'
'"resourceName":"db.t"}',
404,
)
print(error.code)
DefaultErrorHandler.get_instance().accept(error, "unknown")
Observed behavior:
error.code is None
A generic RESTException is raised instead of NoSuchResourceException.
_parse_error_response uses the HTTP status only when parsing fails or when the parsed response has no message. If valid JSON contains a message but omits the optional code , the parsed object is returned unchanged.
Relevant code:
- paimon-python/pypaimon/api/client.py : _parse_error_response
- paimon-python/pypaimon/api/client.py : DefaultErrorHandler.accept
The JVM REST client already falls back to the HTTP status when the parsed error code is null.
What doesn't meet your expectations?
The HTTP status should be used when a valid error response does not contain an application-level code.
A 404 response should map to NoSuchResourceException, a 409 response to AlreadyExistsException, and a 503 response to ServiceUnavailableException.
Returning a generic RESTException can also break catalog operations that rely on typed exceptions for ignore-if-exists or ignore-if-not-exists behavior.
Anything else?
A possible fix is to normalize every successfully parsed response:
if error.code is None:
error.code = status_code
The check should use is None, rather than truthiness.
Suggested tests:
- Valid error JSON without code for HTTP 404
- Valid error JSON without code for HTTP 409
- Valid error JSON without code for HTTP 503
- End-to-end
_execute_request tests asserting the typed exceptions
- Catalog-level ignore-if-missing and ignore-if-existing behavior
Are you willing to submit a PR?
Search before asking
Paimon version
master (1d368b4)
Compute Engine
PyPaimon REST client. Engine-independent.
Minimal reproduce step
Observed behavior:
error.code is None
A generic RESTException is raised instead of NoSuchResourceException.
_parse_error_response uses the HTTP status only when parsing fails or when the parsed response has no message. If valid JSON contains a message but omits the optional code , the parsed object is returned unchanged.
Relevant code:
The JVM REST client already falls back to the HTTP status when the parsed error code is null.
What doesn't meet your expectations?
The HTTP status should be used when a valid error response does not contain an application-level code.
A 404 response should map to NoSuchResourceException, a 409 response to AlreadyExistsException, and a 503 response to ServiceUnavailableException.
Returning a generic RESTException can also break catalog operations that rely on typed exceptions for ignore-if-exists or ignore-if-not-exists behavior.
Anything else?
A possible fix is to normalize every successfully parsed response:
The check should use
is None, rather than truthiness.Suggested tests:
_execute_requesttests asserting the typed exceptionsAre you willing to submit a PR?