Skip to content

fix: build Files list file URLs from id and name - #7797

Open
Rohit3523 wants to merge 1 commit into
developfrom
fix/files-list-file-upload-url
Open

Rohit3523 wants to merge 1 commit into
developfrom
fix/files-list-file-upload-url

Conversation

@Rohit3523

@Rohit3523 Rohit3523 commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

The Files list (channels|groups|im.files) passed each record's stored url straight into the attachment. Uploads made before server 9.0 keep a /ufs/... url, and RocketChat/Rocket.Chat#41054 removes that route without migrating stored urls, so older files show as broken images and dead links.

getFileUrlAndTypeFromMessage now builds /file-upload/{_id}/{encodeURIComponent(name)} from the record and ignores the stored url. This is the same route web's file list now uses, and every supported server serves it, so there is no version gate.

E2E files read the same record: Encryption.decryptFiles overwrites name/type with the decrypted values before the url is built, so the id and name are valid either way.

Issue(s)

https://rocketchat.atlassian.net/browse/NATIVE-1755

How to test or reproduce

  1. In a channel, upload an image, an audio file and a PDF (include a name with a space, # or non-ASCII characters).
  2. Simulate a pre-9.0 upload on a pre-9.0 server by pointing each upload's stored url at a path that 404s, e.g. /ufs/GridFS:Uploads/<id>-gone/<name> on rocketchat_uploads.
  3. Open the room, then Room Actions, then Files.
    • develop: images spin forever, audio stays at 00:00.
    • This branch: images render, audio loads, the PDF opens.
  4. Repeat in an encrypted room. The decrypted file name is shown and the PDF opens.

Tested on an Android emulator against server 8.10 (local) and 8.4 (mobile.qa). Not tested on a 9.0 server or a 3.x workspace; in the 3.0.0 server source the /file-upload/ handler looks the file up by id only.

In an encrypted room the image in the Files list stays on a loading spinner on develop as well (checked with the record's original, working url), so that is separate from this change.

Screenshots

Screen Before After
Older files on < 9.0 (stored /ufs url), cache cleared Old code, 45 s after opening: image still spinning, audio at 00:00, video tile blank PR: image, audio and video load
New files on 9.0 (stored /file-upload url) Old code: image, audio, video and PDF load too PR: image, audio, video and PDF load, including a name with a space, # and non-ASCII characters
Cached files on 9.0 (/file-upload blocked, served from the cache) Old code: image and video load from the cache too PR: image and video load from the cache

9.0 behaviour is simulated on a local 8.10 server: /ufs answers like a removed route and the records use the 9.0 url shape. Android emulator, throwaway account. Rows 2 and 3 already work on develop (the stored url is valid, and the cached files are found); they are here to show no regression.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Unit tests cover all four attachment types, a legacy /ufs stored url being ignored, a missing url, and name encoding (space, #, ?, %, /, non-ASCII).

After upgrading the app from a develop release build to this branch's release build (Android emulator, local 8.10 workspace, app data kept), the files in the Files list are still visible and everything looks good.

Summary by CodeRabbit

  • Bug Fixes
    • File links for images, audio, video, and other attachments now use the uploaded file’s identifier and name, rather than a previously stored URL.
    • Filenames with spaces, special characters, slashes, or non-English characters are encoded so links work correctly.
    • Attachments without a stored URL can now still receive a usable file link.

The Files list used the stored url from the *.files endpoints. Uploads made before server 9.0 keep a /ufs/... url, and that route is removed there (RocketChat/Rocket.Chat#41054), so older files rendered as broken images and dead links. Build /file-upload/{id}/{name} instead, the route every supported server serves.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cbfddd48-d9f2-4585-a9eb-dd60be10716a
📥 Commits

Reviewing files that changed from the base of the PR and between 7f96e6d and 4bc3115.

📒 Files selected for processing (2)
  • app/views/MessagesView/__tests__/getFileUrlAndTypeFromMessage.test.ts
  • app/views/MessagesView/getFileUrlAndTypeFromMessage.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: E2E Shard Preflight
🔇 Additional comments (2)
app/views/MessagesView/getFileUrlAndTypeFromMessage.ts (1)

1-4: LGTM!

Also applies to: 6-7, 9-10, 13-13

app/views/MessagesView/__tests__/getFileUrlAndTypeFromMessage.test.ts (1)

1-54: LGTM!

Walkthrough

The helper now builds file URLs from each file’s ID and encoded name. Tests cover image, audio, video, and other-file results, including filenames with reserved characters and non-ASCII characters.

Changes

File upload URL construction

Layer / File(s) Summary
Construct and validate file URLs
app/views/MessagesView/getFileUrlAndTypeFromMessage.ts, app/views/MessagesView/__tests__/getFileUrlAndTypeFromMessage.test.ts
The helper builds URLs from the file ID and encoded name instead of using the stored URL. Tests cover supported file types, absent stored URLs, and special characters in image filenames.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: type: bug

Merge Risk: ⚪ Minimal · up to 4bc31

No actionable issue is established for the new Files-list URLs. The change is mergeable after normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: building Files list URLs from the file ID and name.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

This branch is waiting to be deployed

3 waiting deployments
ios_build — 4bc3115f Waiting Oct 11, 2026 by Rohit3523 via Build iOS / Hold #7194
android_build — 4bc3115f Waiting Oct 11, 2026 by Rohit3523 via Build Android / Hold #7194
approve_e2e_testing — 4bc3115f Waiting Oct 11, 2026 by Rohit3523 via E2E Hold #7194
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.

1 participant