Skip to content

feat(content-uploader): pass version_number to modernized uploader items list#4623

Merged
mergify[bot] merged 5 commits into
box:masterfrom
olehrybak:modernized-items-list-version-number
Jun 16, 2026
Merged

feat(content-uploader): pass version_number to modernized uploader items list#4623
mergify[bot] merged 5 commits into
box:masterfrom
olehrybak:modernized-items-list-version-number

Conversation

@olehrybak

@olehrybak olehrybak commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Passed version_number to the modernized upload items list
  • Extracted the logic that appends version_number query param to the upload url outside of if (!uploadUrl) so that it can be called when we receive a url from preflight request

Summary by CodeRabbit

  • Chores

    • Updated upload-related dependencies to newer versions.
  • Bug Fixes

    • Fixed upload URL generation so the fields query parameter is consistently included, even when the upload URL is constructed internally.
  • Features

    • Added versionNumber to modernized upload item mapping, sourced from legacy file data when available.
  • Tests

    • Added/updated Jest coverage for fields URL inclusion and versionNumber mapping behavior.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 98accba6-fbb8-4c64-8f71-c86c31fe4740

📥 Commits

Reviewing files that changed from the base of the PR and between e27735e and a5cf1e2.

📒 Files selected for processing (1)
  • package.json

Walkthrough

This PR adjusts PlainUpload to consistently apply field query parameters to all upload URLs, and extends UploadItem mapping to extract version numbers from legacy file objects, with corresponding test coverage.

Changes

Upload Handling and Item Mapping Enhancements

Layer / File(s) Summary
Fields Query Parameter Support in Upload Handler
src/api/uploads/PlainUpload.js, src/api/uploads/__tests__/PlainUpload.test.js
PlainUpload.preflightSuccessHandler now applies the fields query parameter to the final upload URL regardless of whether upload_url is provided or constructed internally. New test verifies the encoded fields query parameter is present in the upload URL.
Version Number Field in Upload Item Mapping
src/elements/content-uploader/utils/mapToModernizedUploadItem.ts, src/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.ts
mapToModernizedUploadItem extracts versionNumber from boxFile.version_number and includes it in the returned UploadItem. Test assertions updated and new cases added to verify field presence and value propagation from legacy file objects.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • box/box-ui-elements#4592: Modifies src/api/uploads/PlainUpload.js to ensure the fields query parameter is correctly appended to upload URLs.
  • box/box-ui-elements#4573: Introduces the mapToModernizedUploadItem mapping logic that this PR extends with versionNumber field extraction.
  • box/box-ui-elements#4563: Modifies @box/uploads-manager dependency declarations in package.json.

Suggested labels

ready-to-merge

Suggested reviewers

  • jpan-box
  • tjuanitas
  • reneshen0328

Poem

🐰 Fields find their rightful place,
Version numbers keep the pace,
Upload URLs gleam so bright,
Items map to version's light,
One more hop—we're nearly right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: passing version_number to modernized uploader items, which aligns with the primary objective of the PR.
Description check ✅ Passed The description includes a clear summary of the two main changes made in the PR, though it omits the template's standard sections beyond the summary.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@socket-security

socket-security Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​box/​uploads-manager@​1.15.0 ⏵ 1.17.277 +1100100 +199 +250
Updatednpm/​@​box/​item-icon@​2.32.14 ⏵ 2.37.583 +1100100 +19950

View full report

@olehrybak
olehrybak marked this pull request as ready for review June 12, 2026 08:55
@olehrybak
olehrybak requested review from a team as code owners June 12, 2026 08:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/api/uploads/__tests__/PlainUpload.test.js (1)

177-196: ⚡ Quick win

Consider adding a test for fields with preflight-provided upload_url.

The new test correctly verifies that fields are appended when the upload URL is constructed internally. However, the PR objective states that fields should be appended "regardless of whether the upload URL is provided initially or returned by preflight." Consider adding a complementary test case where data.upload_url is provided to ensure complete coverage of both code paths.

🧪 Suggested additional test case
+    test('should append fields query parameter when upload URL is provided by preflight', () => {
+        const preflightUploadUrl = 'https://upload.box.com/api/2.0/files/content';
+        upload.isDestroyed = jest.fn().mockReturnValueOnce(false);
+        upload.computeSHA1 = jest.fn().mockReturnValueOnce(Promise.resolve('somehash'));
+        upload.file = {
+            name: 'warlock',
+        };
+        upload.folderId = '123';
+        upload.fields = ['content_created_at', 'version_number'];
+        upload.xhr = {
+            uploadFile: jest.fn(),
+        };
+
+        return upload.preflightSuccessHandler({ data: { upload_url: preflightUploadUrl } }).then(() => {
+            expect(upload.xhr.uploadFile).toHaveBeenCalledWith(
+                expect.objectContaining({
+                    url: `${preflightUploadUrl}?fields=content_created_at%2Cversion_number`,
+                }),
+            );
+        });
+    });
🤖 Prompt for 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.

In `@src/api/uploads/__tests__/PlainUpload.test.js` around lines 177 - 196, Add a
complementary unit test to verify that when preflight returns an upload_url the
upload.fields are still appended to that URL; specifically, create a test that
sets upload.fields (e.g., ['content_created_at','version_number']), mocks
upload.isDestroyed and computeSHA1, sets upload.file/folderId and
upload.xhr.uploadFile, calls upload.preflightSuccessHandler({ data: {
upload_url: 'https://host/some/path' } }) and asserts upload.xhr.uploadFile was
called with an object whose url equals the provided upload_url plus the query
parameter ?fields=content_created_at%2Cversion_number; this ensures both code
paths (constructed URL and preflight-provided upload_url) handle upload.fields
correctly.
🤖 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 `@package.json`:
- Line 150: Verify that bumping `@box/uploads-manager` to 1.17.2 doesn’t introduce
breaking API/type changes by auditing uses of UploadItemStatus, UploadItem, and
UploadsManager in the repo: search for references to those symbols, update any
call sites or type annotations to match the new package typings if they changed,
and run the content-uploader test suite (unit and integration) to catch
runtime/type regressions; if tests fail, pin the dependency back or apply
necessary code changes to adapt to the new API.

---

Nitpick comments:
In `@src/api/uploads/__tests__/PlainUpload.test.js`:
- Around line 177-196: Add a complementary unit test to verify that when
preflight returns an upload_url the upload.fields are still appended to that
URL; specifically, create a test that sets upload.fields (e.g.,
['content_created_at','version_number']), mocks upload.isDestroyed and
computeSHA1, sets upload.file/folderId and upload.xhr.uploadFile, calls
upload.preflightSuccessHandler({ data: { upload_url: 'https://host/some/path' }
}) and asserts upload.xhr.uploadFile was called with an object whose url equals
the provided upload_url plus the query parameter
?fields=content_created_at%2Cversion_number; this ensures both code paths
(constructed URL and preflight-provided upload_url) handle upload.fields
correctly.
🪄 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: CHILL

Plan: Pro

Run ID: aee7135a-79ca-41b0-87ab-fe599be9ee22

📥 Commits

Reviewing files that changed from the base of the PR and between d4605b9 and abd1679.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • package.json
  • src/api/uploads/PlainUpload.js
  • src/api/uploads/__tests__/PlainUpload.test.js
  • src/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.ts
  • src/elements/content-uploader/utils/mapToModernizedUploadItem.ts

Comment thread package.json
Omfalos
Omfalos previously approved these changes Jun 12, 2026

@Omfalos Omfalos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

dlasecki-box
dlasecki-box previously approved these changes Jun 12, 2026
Comment thread package.json
@olehrybak
olehrybak force-pushed the modernized-items-list-version-number branch from abd1679 to e27735e Compare June 15, 2026 10:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
package.json (1)

307-307: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Update @box/item-icon version in peerDependencies to match devDependencies.

Line 139 bumps @box/item-icon to ^2.37.5 in devDependencies, but Line 307 still declares ^2.32.14 in peerDependencies. All other upgraded dependencies (@box/activity-feed, @box/blueprint-web, @box/blueprint-web-assets, @box/collaboration-popover, @box/readable-time, @box/threaded-annotations, @box/user-selector, @box/uploads-manager) maintain consistent versions across both sections. This mismatch will cause peer dependency resolution warnings or errors for consumers of this package.

🔧 Proposed fix
-        "`@box/item-icon`": "^2.32.14",
+        "`@box/item-icon`": "^2.37.5",
🤖 Prompt for 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.

In `@package.json` at line 307, Update the version of the `@box/item-icon`
dependency in the peerDependencies section to match the version specified in
devDependencies. The peerDependencies entry for `@box/item-icon` is currently
pinned to ^2.32.14 while devDependencies has been updated to ^2.37.5. Change the
peerDependencies version of `@box/item-icon` from ^2.32.14 to ^2.37.5 to maintain
consistency with other upgraded dependencies and prevent peer dependency
resolution warnings for package consumers.
🤖 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.

Outside diff comments:
In `@package.json`:
- Line 307: Update the version of the `@box/item-icon` dependency in the
peerDependencies section to match the version specified in devDependencies. The
peerDependencies entry for `@box/item-icon` is currently pinned to ^2.32.14 while
devDependencies has been updated to ^2.37.5. Change the peerDependencies version
of `@box/item-icon` from ^2.32.14 to ^2.37.5 to maintain consistency with other
upgraded dependencies and prevent peer dependency resolution warnings for
package consumers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 00016147-dac4-4e1d-b6ef-675976a2af08

📥 Commits

Reviewing files that changed from the base of the PR and between abd1679 and e27735e.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • package.json
  • src/api/uploads/PlainUpload.js
  • src/api/uploads/__tests__/PlainUpload.test.js
  • src/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.ts
  • src/elements/content-uploader/utils/mapToModernizedUploadItem.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/elements/content-uploader/utils/tests/mapToModernizedUploadItem.test.ts
  • src/elements/content-uploader/utils/mapToModernizedUploadItem.ts
  • src/api/uploads/PlainUpload.js

@jfox-box jfox-box left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@mergify

mergify Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-06-16 09:14 UTC · Rule: Automatic strict merge
  • Checks skipped · PR is already up-to-date
  • Merged2026-06-16 09:15 UTC · at a5cf1e28b783cd6ed1fbd5c160172312b414e41f · squash

This pull request spent 1 minute 19 seconds in the queue, including 21 seconds running CI.

Required conditions to merge

@mergify
mergify Bot merged commit f28d203 into box:master Jun 16, 2026
9 of 10 checks passed
@mergify mergify Bot removed the queued label Jun 16, 2026
kduncanhsu pushed a commit to kduncanhsu/box-ui-elements that referenced this pull request Jun 18, 2026
…ems list (box#4623)

* feat(content-uploader): pass version_number to modernized uploader items list

* feat: bump uploads-manager package

* feat: bump @box/item-icon version

* feat: bump @box/item-icon version

* fix: bump @box/item-icon version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants