Skip to content

Reject duplicate multipart field names in manifest uploads and full scans - #132

Open
lelia wants to merge 5 commits into
mainfrom
lelia/ce-449-sdk-reject-duplicate-multipart-field-keys
Open

lelia wants to merge 5 commits into
mainfrom
lelia/ce-449-sdk-reject-duplicate-multipart-field-keys

Conversation

@lelia

@lelia lelia commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Manifest uploads and full scans can produce duplicate multipart field names when paths repeat, normalize to the same key, or are stripped against different base paths. The SDK now raises ValueError before sending the request and includes the colliding field name and both sources.

Changes

  • Share path-to-key calculation between eager and lazy manifest uploads. Compare field names using the installed multipart encoder’s escaping rules.
  • Validate lazy uploads before changing the shared file descriptor limit, so rejecting a duplicate leaves open files alone.
  • Use explicit filenames for diagnostics on prepared full-scan parts. Preserve Requests-compatible encoding for valid uploads.
  • Preserve repeated-field behavior for dependency uploads and repo-based diff scans. Bump the SDK patch version to 3.6.5.

Validation

  • Unit suite on urllib3 2.8.0 and 1.26.20, each with 261 passed, 1 skipped, and 97 subtests passed.
  • Regression tests cover duplicate path normalization and multipart escaping, descriptor-limit ordering, explicit filenames on prepared streams, and repeated fields on the other lazy upload endpoints.
  • Source and wheel builds, Twine checks, and an isolated import from the wheel passed.

Public Changelog

Reject duplicate multipart field names before sending manifest uploads or full scans, with an error naming the colliding field and both sources.

Fixes CE-449

@lelia
lelia requested a review from a team as a code owner November 14, 2026 05:35
@cursor

cursor Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes upload validation for manifest and full-scan flows; callers that previously relied on silent overwrites will now get errors, while dependency/diff-scan behavior is intentionally unchanged.

Overview
Manifest uploads and full scans now fail fast when two inputs would use the same multipart field name, instead of silently dropping one file on the wire. Collisions are detected before any HTTP request (and before opening files or adjusting the shared lazy-upload file-descriptor limit), with a ValueError that names the escaped field key and both source paths.

Upload path-to-key logic is centralized in Utils (calculate_upload_key, calculate_upload_keys, validate_upload_keys), so lazy and eager manifest uploads share the same normalization and compare keys using the installed urllib3/Requests multipart encoder (including byte vs string keys and percent-encoded names). UploadManifests drops its duplicated key logic in favor of these helpers.

Full scans validate duplicates on both lazy path-key uploads and caller-supplied multipart entries (non-lazy), while still forwarding valid files shapes unchanged. Dependency uploads and repo diff scans opt out via reject_duplicate_keys=False so repeated fields behave as before.

Release 3.6.5 with changelog; broad unit coverage for collision cases, ordering, and encoder alignment.

Reviewed by Cursor Bugbot for commit 45ee085. Configure here.

@lelia

lelia commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@lelia lelia changed the title Reject duplicate multipart upload keys before sending files Reject duplicate multipart field names in manifest uploads and full scans Dec 5, 2026
@lelia

lelia commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 45ee085. Configure here.

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.

1 participant