Skip to content

fix(attachments): prevent crash when attachment fields are non-string#39273

Open
metaloozee wants to merge 4 commits into
RocketChat:developfrom
metaloozee:develop
Open

fix(attachments): prevent crash when attachment fields are non-string#39273
metaloozee wants to merge 4 commits into
RocketChat:developfrom
metaloozee:develop

Conversation

@metaloozee
Copy link
Copy Markdown

@metaloozee metaloozee commented Mar 3, 2026

Proposed changes (including videos or screenshots)

This PR fixes a client-side crash when opening a channel that contains integration attachments with non-string field values (for example, integers).

In DefaultAttachment.tsx, attachment field title/value were processed with .replace() under the assumption they were strings.
When integrations sent numeric values, rendering failed and the channel could not be opened in the browser app.

Changes:

  • Safely coerce attachment field title and value to strings before markdown formatting/rendering.
  • Preserve current rendering behavior for existing string inputs.

Issue(s)

Closes #39264

Summary by CodeRabbit

  • Bug Fixes
    • Improved message attachment content handling to ensure proper rendering with different input types.

@metaloozee metaloozee requested a review from a team as a code owner March 3, 2026 09:52
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Mar 3, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: 78965fb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 3, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 3, 2026

Walkthrough

A bug fix that ensures non-string inputs in FieldsAttachment are coerced to strings before being processed by MarkdownText. The title and value fields now wrap with String(...) to prevent potential type-related issues during markdown rendering.

Changes

Cohort / File(s) Summary
Type Coercion Fix
apps/meteor/client/components/message/content/attachments/DefaultAttachment.tsx
Added explicit string coercion using String(...) wrapper around title and value fields before passing to MarkdownText component to handle non-string inputs safely.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(attachments): prevent crash when attachment fields are non-string' accurately describes the main change: preventing crashes by handling non-string attachment fields through type coercion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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


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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

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.

Attachment with integer value lead to failure of loading channel content on browser app

3 participants