Skip to content

Update version to 0.19.1 and improve file upload initiation#70

Merged
parashardhapola merged 1 commit intomasterfrom
r2_fixes
Mar 7, 2026
Merged

Update version to 0.19.1 and improve file upload initiation#70
parashardhapola merged 1 commit intomasterfrom
r2_fixes

Conversation

@parashardhapola
Copy link
Member

  • Bump package version to 0.19.1.
  • Modify the file upload initiation to include the file size in the request, enhancing the upload process.
  • Update validation logic to ensure the number of presigned URLs is at least equal to the expected chunk count, improving error handling during uploads.

- Bump package version to 0.19.1.
- Modify the file upload initiation to include the file size in the request, enhancing the upload process.
- Update validation logic to ensure the number of presigned URLs is at least equal to the expected chunk count, improving error handling during uploads.
@qodo-code-review
Copy link

Review Summary by Qodo

Version 0.19.1: Enhance file upload with size parameter

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Bump package version to 0.19.1
• Include file size in upload initiation request
• Relax presigned URL validation to allow extra URLs
• Improve error message clarity for URL count mismatches
Diagram
flowchart LR
  A["Upload Initiation"] -->|"Include file_size_bytes"| B["post_json Request"]
  B -->|"Receive presigned URLs"| C["Validation Logic"]
  C -->|"Changed: != to <"| D["Allow Extra URLs"]
  D -->|"Improved error message"| E["Better Error Handling"]
Loading

Grey Divider

File Changes

1. cytetype/__init__.py ⚙️ Configuration changes +1/-1

Bump version to 0.19.1

• Update package version from 0.19.0 to 0.19.1

cytetype/init.py


2. cytetype/api/client.py ✨ Enhancement +7/-3

Enhance upload initiation and URL validation logic

• Change upload initiation from post_empty to post_json to include file size
• Add file_size_bytes parameter in the request payload
• Relax presigned URL validation from exact match (!=) to minimum requirement (<)
• Update error message to reflect that extra URLs are acceptable

cytetype/api/client.py


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Mar 7, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Extra URLs silently accepted 🐞 Bug ⛯ Reliability
Description
The presigned URL validation was relaxed from rejecting any mismatch to only rejecting “too few”
URLs. Since the client uploads exactly n_chunks (derived from size_bytes/chunk_size_bytes) and
completes with exactly n_chunks parts, accepting extra URLs can mask a server/client chunking
mismatch and defer a clear error until late (after time/bandwidth is spent).
Code

cytetype/api/client.py[R80-84]

+    if use_r2 and len(presigned_urls) < n_chunks:  # type: ignore[arg-type]
        raise ValueError(
            f"Server returned {len(presigned_urls)} presigned URLs "  # type: ignore[arg-type]
-            f"but expected {n_chunks} (one per chunk)."
+            f"but need at least {n_chunks} (one per chunk)."
        )
Evidence
The client computes n_chunks and only ever uploads chunk indices in range(n_chunks), indexing
presigned URLs by chunk_idx. It then completes multipart upload with exactly n_chunks parts.
Therefore, if the server returns more presigned URLs than n_chunks, the extras are ignored and any
underlying contract mismatch is no longer caught early by validation.

cytetype/api/client.py[74-84]
cytetype/api/client.py[117-127]
cytetype/api/client.py[210-217]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The client now accepts `len(presigned_urls) &gt; n_chunks` without any signal. Since the client only uploads `range(n_chunks)` and completes with exactly `n_chunks` parts, extra URLs are ignored and a server/client mismatch can be detected only after spending time uploading.

## Issue Context
This validation was intentionally relaxed to allow `&gt;= n_chunks`, but the codebase has no other safeguard or observability to detect “too many URLs” as a potential contract mismatch.

## Fix Focus Areas
- cytetype/api/client.py[74-85]
- cytetype/api/client.py[117-127]
- cytetype/api/client.py[210-217]িম

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@parashardhapola parashardhapola merged commit 98cbecd into master Mar 7, 2026
1 check passed
@parashardhapola parashardhapola deleted the r2_fixes branch March 7, 2026 18:20
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.

1 participant