feat(lint): error when a video or img src is the other media kind - #3609
Merged
Conversation
Agents were shipping <video src="….jpg"> / <img src="….mov"> because the existing URL-resolvable check stayed green. Report an error so the agent rewrites the tag; skip audio, <source>, and extensionless URLs.
xuanruli
marked this pull request as ready for review
September 3, 2026 04:49
miguel-heygen
approved these changes
Sep 3, 2026
miguel-heygen
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at exact head 692580de744f2199426bedeba3ebe2f00d481d44.
packages/lint/src/rules/media.ts:44-130keeps the rule on the provable cases only: element-owned<video>/<img>src, closed image/video suffix sets, data MIME support, case-folding, query/hash stripping, and explicit fail-open for blob/extensionless input. The suffix vocabulary matches EF's sharedget_resource_type_from_extensionimage/video sets today.- The finding reconstructs a bounded diagnostic without echoing the full src, is severity
error, and leaves<audio>/<source>to their separate policies. media.test.ts:799-868discriminates both mismatch directions, data-image input, healthy matches, and the extensionless/audio carve-outs. Exact-head CI has zero non-passing checks.
Non-blocking: the suffix vocabulary is still manually duplicated across OSS and EF, so a parity fixture would be useful if either set grows.
Verdict: APPROVE
Reasoning: The rule fails only on extension/MIME evidence that proves a tag-kind mismatch, covers both directions, and preserves the intended ambiguous-source carve-outs.
— Magi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a
media_src_kind_mismatchlint error when a<video>element's ownsrcis an image, or an<img>element's ownsrcis a video.Why
The existing media-src check only asks whether
srcis a resolvable URL, so<video src="still.jpg">and<img src="clip.mov">lint green. Agents then ship that HTML; the producer later fail-closes because the tag and file kind disagree.Companion bake-time rewrite (does not live here): https://github.com/heygen-com/experiment-framework/pull/49536
How
Classify the element's own
srcfromdata:MIME or file extension. This rule is an error, so it only fires on cases that cannot be a false positive:<video src>whose path/MIME is an image<img src>whose path/MIME is a videoSkipped on purpose (extension cannot prove a producer failure):
blob:, extensionless URLs,<audio>(including<audio src="*.mp4">SFX), and<source>.Test plan
packages/lint/src/rules/media.test.ts: video+jpg, img+mov, data:image, matching kinds, extensionless + audio)Made with Cursor