Skip to content

fix: enforce append size validation across storage backends and support chunked creation - #150

Merged
tomdesair merged 1 commit into
masterfrom
bugfix/append-size-validation
Oct 25, 2026
Merged

tomdesair merged 1 commit into
masterfrom
bugfix/append-size-validation

Conversation

@tomdesair

Copy link
Copy Markdown
Owner

Summary

Enforces append size validation (maxAppendSize and minAppendSize) across all storage backends (Disk, S3, Azure Blob) during stream append operations, and introduces robust detection for chunked and streaming creation requests without Content-Length.

Details

  • Append Size Validation: Added validateMaxAppendSize and validateMinAppendSize checks in DiskStorageService and AzureBlobStorageService ensuring transfers exceeding maxAppendSize or falling below minAppendSize (when not completing) truncate and throw typed exceptions (MaxAppendSizeExceededException, MinAppendSizeNotMetException).
  • Stream Peeking for Chunked / Streamed Creation:
    • Implemented TusServletRequest.hasContent() which conforms to RFC 9112 §6.3 (Transfer-Encoding overrides Content-Length).
    • When Content-Length is omitted or negative, peeks 1 byte via PushbackInputStream and unreads it to detect whether content exists without consuming bytes from the stream.
    • Updated CreationWithUploadPostRequestHandler (Tus v1.0.0) and RufhCreationPostRequestHandler (RUFH Draft-12) to use servletRequest.hasContent().
    • Empty chunked creation requests (0\r\n\r\n or empty bodies without Content-Length) now cleanly succeed without erroneously triggering MinAppendSizeNotMetException.
  • Conformity Testing:
    • Added test_chunked_append_and_creation_enforce_max_append_size and test_chunked_append_and_creation_enforce_min_append_size to scripts/rufh_conformity_test.py.
    • All RUFH (57/57) and Tus v1.0.0 (55/55) conformity tests pass across Disk, S3, and Azure Blob storage backends.
  • Unit & Integration Tests:
    • Added unit test cases to TusServletRequestTest, CreationWithUploadPostRequestHandlerTest, RufhCreationPostRequestHandlerTest, and DiskStorageServiceTest.
    • Added multi-backend integration tests testCreationWithUploadChunkedTransferEncoding and testCreationWithUploadChunkedEmptyBody to AbstractITTusFileUploadService.

…rt chunked creation

- Validate maxAppendSize and minAppendSize in DiskStorageService and AzureBlobStorageService during stream append
- Introduce TusServletRequest.hasContent() with PushbackInputStream peeking to accurately detect content when Content-Length is omitted or negative
- Update CreationWithUploadPostRequestHandler and RufhCreationPostRequestHandler to use TusServletRequest.hasContent()
- Add chunked append and creation validation tests to python conformity test suite (rufh_conformity_test.py)
- Add comprehensive unit and multi-backend integration tests for append size enforcement and chunked creation
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 95.07% (+0.04%) from 95.034% — bugfix/append-size-validation into master

@tomdesair
tomdesair merged commit 431e138 into master Oct 25, 2026
13 checks passed
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