#16069·chatwoot

Messages with a markdown image that has a relative or malformed URL throw TypeError: Invalid URL

Author: sarmah-rupCreated Sep 29, 2026Updated Sep 29, 2026

Describe the bug

MessageFormatter throws TypeError: Invalid URL for any message containing a markdown image whose src is not an absolute URL, such as a relative path (/uploads/a.png, logo.png) or a malformed one (http://).

setImageSizing in app/javascript/shared/helpers/MessageFormatter.js reads the cw_image_width / cw_image_height params with new URL(imgSrc), without a base URL. That works for https://... sources and throws for everything else. The formatter renders dashboard message bubbles (components-next/message/bubbles/Text/FormattedContent.vue), reply previews (bubbles/Base.vue) and widget messages, and message content can come straight from a contact, so one such image is enough to stop that message from being formatted.

To Reproduce

javascript
import MessageFormatter from 'shared/helpers/MessageFormatter';

new MessageFormatter('Screenshot ![](/uploads/screenshot.png)').formattedMessage;
// TypeError: Invalid URL: /uploads/screenshot.png

new MessageFormatter('![](http://)').formattedMessage;
// TypeError: Invalid URL: http://

Expected behavior

The message is formatted. The image keeps its src as written, and cw_image_height / cw_image_width still apply when present.

Environment

Frontend code on develop (a851d63c). Not deployment specific.

The Captain document view already avoids this by calling disableImageRendering(), but every other caller still goes through setImageSizing.