Skip to content

fix: correct multipart part numbering and selectObjectContent XML payload - #1492

Open
prakashsvmx wants to merge 2 commits into
minio:masterfrom
prakashsvmx:fix/upload-stream-partnumber-and-select-object-content
Open

fix: correct multipart part numbering and selectObjectContent XML payload#1492
prakashsvmx wants to merge 2 commits into
minio:masterfrom
prakashsvmx:fix/upload-stream-partnumber-and-select-object-content

Conversation

@prakashsvmx

@prakashsvmx prakashsvmx commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

  • uploadStream part numbering: Removes a duplicate partNumber++ that caused fresh multipart uploads to number parts as 1, 3, 5, … instead of 1, 2, 3. The counter is already incremented at the top of the loop; the stray second increment after each upload doubled the step for every uploaded chunk (skipped chunks were unaffected because continue bypassed it).

  • selectObjectContent malformed XML: Fixes the request body being built as an Array<Record<string, unknown>> instead of a flat Record<string, unknown>. xml2js.Builder.buildObject() expects an object — passing an array produced numeric-keyed <0>…</0><1>…</1> elements rather than the expected <Expression>, <ExpressionType>, etc., causing MinIO/S3 to reject the request with MethodNotAllowed.

  • Functional test resilience: Replaces the host-name-based skip guard on the Select Object Content test with a runtime MethodNotAllowed catch, so the test exercises the API on servers that support S3 Select and silently passes through on those that don't.

Test plan

  • Unit tests: uploadStream multipart part numbering — all 3 cases pass (1,2,3 fresh; resume skip; mismatch re-upload)
  • Functional tests: selectObjectContent step passes against a MinIO server that supports S3 Select
  • Functional tests: selectObjectContent step silently skips (no failure) against a MinIO AIStor server that does not support S3 Select
  • Full test suite: 432 passing, 3 pending, 0 failing

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability for resumed multipart uploads by ensuring part numbers advance correctly during chunked uploads.
    • Corrected Select Object Content request formatting to better support optional progress and scan range settings.
  • Tests
    • Updated functional Select Object Content coverage to be more resilient: lifecycle setup/cleanup is now conditional on successful creation, and unsupported operations are skipped instead of failing.

…load

- Remove duplicate partNumber++ in uploadStream that caused fresh uploads
  to number parts as 1,3,5 instead of 1,2,3 (regression from minio#1490)
- Fix selectObjectContent building XML body as array-of-objects instead
  of a flat object, which produced malformed XML rejected by S3/MinIO
- Functional test: replace host-name guard on Select test with a runtime
  MethodNotAllowed catch so the test runs and passes on supporting servers
  and silently skips on servers that don't implement S3 Select
@prakashsvmx
prakashsvmx force-pushed the fix/upload-stream-partnumber-and-select-object-content branch from 32ca789 to dc35761 Compare July 30, 2026 10:24
@prakashsvmx prakashsvmx self-assigned this Jul 30, 2026
@prakashsvmx
prakashsvmx requested a review from grahit13 July 30, 2026 10:26
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 71fb0023-47c7-4bbd-8c60-704c5093fc4b

📥 Commits

Reviewing files that changed from the base of the PR and between dc35761 and b9955ff.

📒 Files selected for processing (1)
  • tests/functional/functional-tests.js

📝 Walkthrough

Walkthrough

Corrects resumed multipart upload part numbering, changes Select Object Content payload construction to an object-shaped configuration, and updates functional tests for asynchronous bucket cleanup and unsupported-operation handling.

Changes

Multipart upload

Layer / File(s) Summary
Correct resumed upload part numbering
src/internal/client.ts
Removes a redundant partNumber increment from the multipart upload loop.

Select Object Content

Layer / File(s) Summary
Build Select request configuration and handle test outcomes
src/internal/client.ts, tests/functional/functional-tests.js
Builds the Select payload from a single configuration object, awaits bucket lifecycle hooks, conditionally removes created buckets, and skips MethodNotAllowed results.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: grahit13, maximilize

Poem

I’m a rabbit with parts in a row,
No duplicate numbers now flow.
Select fields hop into place,
Tests clean up with async grace.
If methods aren’t allowed, we skip—
Then safely onward, carrot-quick!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main code fixes: multipart part numbering and the selectObjectContent XML payload.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/functional/functional-tests.js`:
- Around line 4624-4630: Update the S3 Select error handler in the enclosing
test callback to use a regular function so Mocha’s context is available, then
call this.skip() when err.code is MethodNotAllowed instead of done(). Preserve
done(err) for all other failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 43fffa66-57ff-4497-b2f7-534209a7de8e

📥 Commits

Reviewing files that changed from the base of the PR and between 9e59f4d and dc35761.

📒 Files selected for processing (2)
  • src/internal/client.ts
  • tests/functional/functional-tests.js

Comment thread tests/functional/functional-tests.js
Switch the selectObjectContent step callback from an arrow function to a
regular function so Mocha's context is available, then call this.skip()
when the server returns MethodNotAllowed instead of done(), which was
incorrectly marking the step as passed on unsupported 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