Skip to content

Conversation

@sungwy
Copy link
Contributor

@sungwy sungwy commented Feb 22, 2025

The existence of the 419 AuthenticationTimeoutResponse status code caused confusion in the Iceberg community on the following two questions:

  • whether the error response should be issued by a REST catalog on token expiry over 401 UnauthorizedResponse
  • and how the client should respond on 419 response (vs a 401 response)

The updated description follows the RFC language of using SHOULD and MAY to be make these more clear for the REST catalog as well as the client responding to the status response.

@sungwy sungwy requested a review from flyrain February 22, 2025 23:20
Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Thanks for the spec clarification, @sungwy ! The changes LGTM 👍

@sungwy
Copy link
Contributor Author

sungwy commented Feb 26, 2025

Thanks for the spec clarification, @sungwy ! The changes LGTM 👍

All thanks to you for the helpful reviews @dimas-b 💯

Credentials have timed out. If possible, the client should refresh credentials and retry.
This is an optional status response type that the REST Catalog can issue when the
token has expired. The client MAY request a new access token and retry the request.
401 UnauthorizedResponse SHOULD be preferred over this response type on token expiry.
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the new descriptions for both status codes. With the new changes, it seems we actually deprecated it without saying it explicitly. Should we just deprecate it then? cc @danielcweeks @rdblue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank @flyrain !

Yeah I was actually debating on the last line, but decided to keep it to facilitate this discussion. I believe a deprecation would result in us removing the status code in a subsequent release, after which the status code handling could also be removed from the Iceberg REST client representations which I think may cause confusion as 419 responses from Iceberg REST Catalog servers that are running on older versions of the spec won't be handled as expected. Hence, I'm hesitant to suggest deprecating the status code.

I still think it's still fair to express a preference as we did here, so as to not confuse the REST Catalog server implementer on which status code to choose to use on token expiry.

Copy link
Contributor

Choose a reason for hiding this comment

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

From my POV the "401 should be preferred" language is already effectively deprecating 419.

However, from the spec evolution perspective, I do not think it would be valid to remove 419 from the v1 REST spec.

All in all, I think the "should" language adds enough clarity for both clients and servers.

Copy link
Contributor

Choose a reason for hiding this comment

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

may cause confusion as 419 responses from Iceberg REST Catalog servers that are running on older versions of the spec won't be handled as expected.

Can you elaborate it? I think the clients are OK to treat a 419 as a 401, or just a normal failure in that case. To retry or not is the client side decision. I believe either behavior(client retry or not retry) is acceptable. My only concern to deprecate it is the SigV4 use case @danielcweeks and @rdblue mentioned, if SigV4 clients must depend on 419, we need to keep it. But I don't have much context, will appreciate any inputs.

Copy link
Contributor Author

@sungwy sungwy Feb 28, 2025

Choose a reason for hiding this comment

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

To retry or not is the client side decision

Yes I agree with you @flyrain . Although I think it'll be confusing for application developers if for example, PyIceberg removed retry handling for 419 status on the next version after the 419 status code is deprecated on the REST Catalog. The application developer would expect 419 status codes from their REST Catalog server to result in retries, and on version upgrade they their PyIceberg application no longer will. Hence, as a community, we may need to keep 419 status code handling for backward compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

The application developer would expect 419 status codes from their REST Catalog server to result in retries

yeah, that's an edge case, in which a server happened to return 419, plus an application happened to rely on 419 for retrying. As we all agreed that 419-based retry is not reliable and not recommended, application shouldn't do that afterward. These are very subtle things though. I'm fine with not deprecate it, but I still prefer to give users more clear message, that 419 shouldn't be used. Deprecating it makes it more clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

Brought this up in last community catalog meeting. The general agreement was to deprecate 419. Meeting link: https://www.youtube.com/watch?v=vbV2XxOTyT4.

sungwy added a commit to apache/iceberg-python that referenced this pull request Mar 3, 2025
This is a follow up item from a recent discussion on the mailing
list[1], where the community decided that 401 response should be
preferred over 419 response on token expiry.

[1] mailing list discussion:
https://lists.apache.org/thread/443skhqr59j3fj0ovg4tyxh9d4f4gysc
[2] REST Catalog Spec update PR:
apache/iceberg#12376
description:
Unauthorized. Authentication is required and has failed or has not yet been provided.
Unauthorized. The REST Catalog SHOULD respond with the 401 UnauthorizedResponse when
the access token provided is expired, revoked, malformed, or invalid for other reasons.
Copy link
Contributor

Choose a reason for hiding this comment

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

If an access token is malformed, wouldn't a 400 / BadRequestErrorResponse be a more appropriate response? I'm wondering if we should drop the malformed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @mrcnc thank you for the review!

IHMO I think if the access token is malformed, I'd still consider 401 to be the appropriate respones type vs 400 which I think would be more appropriate when the format of the Request itself is malformed.

I took this verbiage directly from https://www.rfc-editor.org/rfc/rfc6750 under the invalid_token section:

invalid_token
         The access token provided is expired, revoked, malformed, or
         invalid for other reasons.  The resource SHOULD respond with
         the HTTP 401 (Unauthorized) status code.  The client MAY
         request a new access token and retry the protected resource
         request.

Fokko pushed a commit to apache/iceberg-python that referenced this pull request Apr 25, 2025
This is a follow up item from a recent discussion on the mailing
list[1], where the community decided that 401 response should be
preferred over 419 response on token expiry.

[1] mailing list discussion:
https://lists.apache.org/thread/443skhqr59j3fj0ovg4tyxh9d4f4gysc
[2] REST Catalog Spec update PR:
apache/iceberg#12376
@github-actions
Copy link

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Apr 26, 2025
@flyrain
Copy link
Contributor

flyrain commented Apr 26, 2025

Hi @sungwy, are you still working on it?

@github-actions github-actions bot removed the stale label Apr 27, 2025
@sungwy
Copy link
Contributor Author

sungwy commented Apr 27, 2025

Hi @sungwy, are you still working on it?

Hi @flyrain I'm still waiting on an approval to merge this in.

Is the direction that we want to make it more clear that we are deprecating 419 status code? If so, I can send out an email on the dev list to vote on the deprecation and proceed from there.

@flyrain
Copy link
Contributor

flyrain commented Apr 30, 2025

Hi @sungwy, thanks for the reply. I'm OK with moving forward with this PR. We could deprecate it in a followup one.

@dimas-b
Copy link
Contributor

dimas-b commented Apr 30, 2025

@flyrain : feel free to merge (from my POV)

@sungwy
Copy link
Contributor Author

sungwy commented May 1, 2025

Merging it in :)

@sungwy sungwy merged commit bd9353a into apache:main May 1, 2025
12 checks passed
@sungwy sungwy deleted the explicit-error-codes branch May 1, 2025 01:26
@sungwy
Copy link
Contributor Author

sungwy commented May 1, 2025

Thanks for the review @flyrain and @dimas-b ! 😁

gabeiglio pushed a commit to Netflix/iceberg-python that referenced this pull request Aug 13, 2025
This is a follow up item from a recent discussion on the mailing
list[1], where the community decided that 401 response should be
preferred over 419 response on token expiry.

[1] mailing list discussion:
https://lists.apache.org/thread/443skhqr59j3fj0ovg4tyxh9d4f4gysc
[2] REST Catalog Spec update PR:
apache/iceberg#12376
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.

4 participants