Skip to content

Core: Extract REST SigV4 signing into a dedicated module - #4493

Open
Anurag-S1ngh wants to merge 2 commits into
apache:mainfrom
Anurag-S1ngh:fix/3410-extract-sigv4
Open

Anurag-S1ngh wants to merge 2 commits into
apache:mainfrom
Anurag-S1ngh:fix/3410-extract-sigv4

Conversation

@Anurag-S1ngh

@Anurag-S1ngh Anurag-S1ngh commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

RestCatalog._init_sigv4 currently contains the SigV4 adapter, signing constants, and boto session setup inside an already large catalog module.

This extracts that code into catalog/rest/sigv4.py and replaces the method with an init_sigv4(session, uri, properties) helper. The SigV4 constants and SigV4Adapter now live in catalog/rest/sigv4.py. Signing and retry behavior are unchanged.

The retry behavior in #3008 and signing fixes in #3120 remain separate.

Part of #3410.

Are these changes tested?

Yes. The existing REST SigV4 tests exercise the extracted adapter through RestCatalog.

  • pytest tests/catalog/test_rest.py -m unit: 204 passed
  • ruff check and git diff --check pass
  • ty check reports nothing for the new module; existing catalog diagnostics are unchanged

Are there any user-facing changes?

No behavior change.

Comment thread pyiceberg/catalog/rest/__init__.py Resolved

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Anurag-S1ngh for picking this up, this makes the REST catalog module a lot easier to navigate 👍 There is one thing that needs fixing before we can merge: the move removes SIGV4_REGION, SIGV4_SERVICE, SIGV4_MAX_RETRIES, SIGV4_MAX_RETRIES_DEFAULT and EMPTY_BODY_SHA256 from pyiceberg.catalog.rest, so from pyiceberg.catalog.rest import SIGV4_REGION now raises an ImportError. Sorry, that's partly on me: ruff splits X as X imports into one statement per name, so the re-exports in your first commit were fine, and my comment about grouping them was misleading. The rest are small suggestions. Once this is in, #4586 needs a small rebase to move its change into sigv4.py.

Comment thread pyiceberg/catalog/rest/__init__.py Resolved
Comment thread pyiceberg/catalog/rest/sigv4.py Resolved
Comment thread pyiceberg/catalog/rest/sigv4.py Resolved
Move SigV4Adapter, its constants, and the initialization helper out of RestCatalog._init_sigv4. Re-export the existing public names from catalog.rest for compatibility. Part of apache#3410; signing and retry fixes remain separate.
SigV4Adapter and init_sigv4 were private before the move, so expose them as
_SigV4Adapter and _init_sigv4.

Keep SIGV4_REGION, SIGV4_SERVICE, SIGV4_MAX_RETRIES,
SIGV4_MAX_RETRIES_DEFAULT and EMPTY_BODY_SHA256 importable from
pyiceberg.catalog.rest, as they were before the extraction.

Carry over the request-body content hash and the blank query parameter
handling from main so the module keeps the behavior it had before the move.
@Anurag-S1ngh
Anurag-S1ngh force-pushed the fix/3410-extract-sigv4 branch from 0570ef3 to c29ef34 Compare December 5, 2026 11:47
@Anurag-S1ngh

Copy link
Copy Markdown
Contributor Author

Rebased on main and addressed all three. The constants are re-exported from pyiceberg.catalog.rest again, SigV4Adapter and init_sigv4 are now _SigV4Adapter and _init_sigv4, and the dropped comments are back. #4586's body hash change and the blank query parameter handling now live in sigv4.py. Unit tests and prek pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants