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

Open-API: Error response in the spec don’t align with the expected model. #8914

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

geruh
Copy link
Contributor

@geruh geruh commented Oct 24, 2023

When generating a REST client using the current OpenAPI specification, the non-200 Iceberg error responses are defined as:

{
  "message": "Malformed request",
  "type": "BadRequestException",
  "code": 400
}

However, the provided examples in the spec correctly enclose the error details within an error JSON node:

{
  "error": {
    "message": "Malformed request",
    "type": "BadRequestException",
    "code": 400
  }
}

Iceberg error responses point to the ErrorModel as their schema, as seen here. Following the current convention and returning the above-stated non-200 error structure to the client results in a precondition failure within the ErrorResponseParser. This is due to the parsers expectation for all error responses to be wrapped within the error JSON node.

example: https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L2444

Testing

make lint
OK

@jackye1995
Copy link
Contributor

cc @amogh-jahagirdar @nastra seems like a miss in the spec, unless the OpenAPI error response requires the error nesting by default, but I did not find any reference of that.

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this @geruh

Comment on lines +2334 to +2340
{
"error": {
"message": "The server does not support this operation",
"type": "UnsupportedOperationException",
"code": 406
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This is in line with the PyIceberg implementation:

class ErrorResponseMessage(IcebergBaseModel):
    message: str = Field()
    type: str = Field()
    code: int = Field()


class ErrorResponse(IcebergBaseModel):
    error: ErrorResponseMessage = Field()

Copy link
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@jackye1995
Copy link
Contributor

thanks for the fix, and thanks for the reviews!

@jackye1995 jackye1995 merged commit 9b9b22d into apache:main Oct 25, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants