Skip to content

Don't render videos with relative or invalid URLs, show the error in development builds - #5889

Merged
Eugene (OEvgeny) merged 3 commits into
mainfrom
OEvgeny/fix-video-relative-url
Oct 19, 2026
Merged

Eugene (OEvgeny) merged 3 commits into
mainfrom
OEvgeny/fix-video-relative-url

Conversation

@OEvgeny

@OEvgeny Eugene (OEvgeny) commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Video attachments, video cards, and animation cards threw an error when the video URL was relative or could not be parsed, which hid the whole card, including its title, text, and buttons.

Changelog Entry

Fixed

  • Fixed video and animation cards disappearing in production builds when the video URL is relative or invalid, in PR #5889, by @OEvgeny

Description

VideoContent called new URL(src) to detect YouTube and Vimeo links, which throws for relative URLs and URLs that cannot be parsed, so the whole attachment disappeared in every build. The src prop now requires an absolute URL: development builds fail prop validation and show the existing error for an attachment that fails to render, and production builds, which do not validate props, leave out the video and show the rest of the card. YouTube and Vimeo URLs without a video ID are no longer embedded and play in <video>, like other URLs that cannot be embedded.

Design

  • Relative URLs, including //host/..., are never resolved or requested, because they would point to a different server in each chat client.
  • Development builds reuse the existing error for attachments that fail to render, which replaces the whole card; production builds show the card without the video.
  • Open question: images, audio, and video posters still pass relative URLs to the browser. Should they follow?

Specific Changes

  • Attachment/VideoContent.tsx: src must be an absolute URL, render nothing if it cannot be parsed, embed YouTube and Vimeo only with a video ID
  • Removed the <a href> URL parsing workaround for Internet Explorer
  • Added Attachment/VideoContent.spec.tsx: production builds render nothing for relative and invalid URLs
  • Added __tests__/html2/attachment/video.url.html: development builds show the error for relative and invalid URLs and never request them; YouTube and Vimeo URLs without a video ID play in <video>
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@OEvgeny

Eugene (OEvgeny) commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

TODO: Can we have snaps for this, so we don't break it? Also, dark-green video could work better in this case.

@OEvgeny

Eugene (OEvgeny) commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator Author

Done: the test now snapshots the video attachment, video card, and animation card with a relative URL, plus the player for an unparsable URL, using a dark green video (a player that cannot play is gray, so a loaded video stands out); the YouTube/Vimeo fallbacks load from the network, so they are asserted instead.

@OEvgeny
Eugene (OEvgeny) force-pushed the OEvgeny/fix-video-relative-url branch from db0c765 to 873c215 Compare October 18, 2026 01:52
@OEvgeny

Eugene (OEvgeny) commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

This one is on hold. We're still figuring if we want relative URL support at all.

@OEvgeny

Copy link
Copy Markdown
Collaborator Author

This one can change direction to the opposite: don't render relative URLs surfacing the broken activity/attachment error in dev mode.

@OEvgeny
Eugene (OEvgeny) force-pushed the OEvgeny/fix-video-relative-url branch from 873c215 to f9c2ad9 Compare October 18, 2026 18:44
@OEvgeny Eugene (OEvgeny) changed the title Resolve video URLs against the page and embed YouTube/Vimeo only with a video ID Leave out videos with relative or invalid URLs and embed YouTube/Vimeo only with a video ID Oct 18, 2026
@OEvgeny
Eugene (OEvgeny) force-pushed the OEvgeny/fix-video-relative-url branch from f9c2ad9 to 965c825 Compare October 18, 2026 22:57
Comment thread CHANGELOG.md Outdated
@OEvgeny
Eugene (OEvgeny) force-pushed the OEvgeny/fix-video-relative-url branch 2 times, most recently from 407218d to a9fc9f6 Compare October 19, 2026 01:15
@OEvgeny

Eugene (OEvgeny) commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

Done: src now requires an absolute URL, so development builds fail prop validation and show the usual "render of attachment" error (console names the URL), while production builds leave out the video, keep the card, and never request the relative URL.

@OEvgeny Eugene (OEvgeny) changed the title Leave out videos with relative or invalid URLs and embed YouTube/Vimeo only with a video ID Don't render videos with relative or invalid URLs, show the error in development builds Oct 19, 2026
@OEvgeny
Eugene (OEvgeny) force-pushed the OEvgeny/fix-video-relative-url branch from a9fc9f6 to f6bf999 Compare October 19, 2026 01:16
@OEvgeny
Eugene (OEvgeny) marked this pull request as ready for review October 19, 2026 01:22
Copilot AI balanced review requested due to automatic review settings October 19, 2026 01:22

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread packages/component/src/Attachment/VideoContent.tsx Outdated
Comment thread packages/component/src/Attachment/VideoContent.tsx Outdated

@compulim William Wong (compulim) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nitpicking.

await waitFor(() => expect(absoluteVideoElement.readyState).toBe(HTMLMediaElement.HAVE_ENOUGH_DATA));
await waitFor(() => expect(requestedURLs).toContain(absoluteURL));

// THEN: The relative URLs should never be requested from the server of this page.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's a bit "far" from where the relativeURLs are.

Later, we should consider split this test into multiple (relative, invalid, YouTube/Vimeo).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, we'll split it into relative, invalid and YouTube/Vimeo tests in a follow-up PR after this one merges.

@OEvgeny
Eugene (OEvgeny) enabled auto-merge (squash) October 19, 2026 07:17
@OEvgeny
Eugene (OEvgeny) merged commit 2d892dc into main Oct 19, 2026
32 checks passed
@OEvgeny
Eugene (OEvgeny) deleted the OEvgeny/fix-video-relative-url branch October 19, 2026 07:25
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.

3 participants