Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/joserfc/_rfc7515/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Strategy(Enum):
#: max header content's size in bytes
max_header_length: int = 512
#: max payload content's size in bytes
max_payload_length: int = 8000
max_payload_length: int = 128000
Comment on lines 51 to +52
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Raising the default max_payload_length to 128000 changes JWS size-validation behavior and breaks existing unit tests that currently expect an ExceededSizeError for ~13KB base64url payload segments (e.g. tests/jws/test_compact.py::test_payload_exceeded_size_error uses a 10,000-byte payload before encoding). Please update the test vectors to exceed the new limit (ideally derived from registry.max_payload_length to avoid future drift).

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

128000 is a bit ambiguous (decimal KB vs KiB). Elsewhere the codebase uses * 1024 or powers of two for byte-size limits (e.g. JWE ciphertext limit is 65536 # 64KB). Consider expressing this as 128 * 1024 (131072) or adding an inline comment clarifying that the intent is exactly 128000 bytes.

Suggested change
max_payload_length: int = 128000
max_payload_length: int = 128000 # exactly 128000 bytes

Copilot uses AI. Check for mistakes.
#: max signature's size in bytes
max_signature_length: int = 1024

Expand Down
2 changes: 1 addition & 1 deletion tests/jws/test_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_header_exceeded_size_error(self):

def test_payload_exceeded_size_error(self):
header = json_b64encode({"alg": "HS256"})
exceeded_payload = urlsafe_b64encode(("o" * 10000).encode("utf8"))
exceeded_payload = urlsafe_b64encode(("o" * (128000 + 1)).encode("utf8"))
fake_jws = header + b"." + exceeded_payload + b"." + urlsafe_b64encode(b"o")
self.assertRaises(ExceededSizeError, deserialize_compact, fake_jws, self.key)

Expand Down
Loading