Skip to content

fix(gateway): match MEDIA tags with case-insensitive file extensions#30722

Closed
Kailigithub wants to merge 1 commit into
NousResearch:mainfrom
Kailigithub:fix/media-uppercase-extensions-30526
Closed

fix(gateway): match MEDIA tags with case-insensitive file extensions#30722
Kailigithub wants to merge 1 commit into
NousResearch:mainfrom
Kailigithub:fix/media-uppercase-extensions-30526

Conversation

@Kailigithub

Copy link
Copy Markdown
Contributor

Summary

The media_pattern regex in gateway/platforms/base.py matches MEDIA:<path> tags to extract
media files from agent responses. The regex's file-extension group (png|jpe?g|gif|...) is
compiled case-sensitively, so files with uppercase extensions like photo.JPG or image.PNG
never match. The tag is then silently stripped downstream, producing empty or garbled messages.

Fix

Add re.IGNORECASE to the re.compile() call so that both photo.jpg and photo.JPG are
recognised as valid media paths.

Testing

  • All 21 existing test_platform_base.py media tests pass.
  • Verified locally that uppercase extensions (.JPG, .PNG, .PDF, .OGG, .MP4) now match.
  • Lowercase and mixed-case extensions also work correctly.

Closes #30526

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels May 23, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Superseded by #34844, which consolidates this cluster.

This PR widens the extract_media extension allowlist, which is the right direction — but on its own it leaves the unconditional MEDIA:\s*\S+ strip in place, so a MEDIA: tag with any extension still outside the (now wider) list keeps getting deleted from the body before extract_local_files can pick up the bare path. #34844 fixes both halves: it unifies the two extractors onto a single shared extension set (MEDIA_DELIVERY_EXTS) AND replaces the loose strip with an extension-anchored one, so an unknown-extension path survives in the text instead of vanishing.

Closing as superseded — thanks for surfacing and helping pin down this bug; it was part of getting the full fix right. See #34844.

@teknium1 teknium1 closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Uppercase extensions in MEDIA: tags produce empty messages

3 participants