Skip to content

fix: add .md extension to MEDIA delivery regex#33244

Closed
luow1028 wants to merge 1 commit into
NousResearch:mainfrom
luow1028:fix/add-md-extension-to-media-regex
Closed

fix: add .md extension to MEDIA delivery regex#33244
luow1028 wants to merge 1 commit into
NousResearch:mainfrom
luow1028:fix/add-md-extension-to-media-regex

Conversation

@luow1028

Copy link
Copy Markdown

Summary

Added .md support to the MEDIA: file delivery regex.

Problem

The MEDIA: prefix in gateway responses recognizes file paths by their extension. .md was missing from the whitelist, so sending MEDIA:/path/to/file.md rendered the path as literal text instead of delivering the file as an attachment.

Change

Added md| to the extension alternation in all three copies of the regex pattern:

  • gateway/platforms/base.pyextract_media() (primary delivery path)
  • gateway/run.py_TOOL_MEDIA_RE (history message scan)
  • gateway/run.py_TOOL_MEDIA_RE (tool output scan)

Testing

Verified by sending MEDIA:/tmp/dflash.md through the Telegram gateway — .md file now delivers as a native document attachment.

The MEDIA: file delivery regex in base.py and run.py didn't include
.md files, causing .md attachments to be rendered as literal text.

Add "md" to the extension alternation in all three regex copies.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have labels May 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #29609 (preferred approach: dynamically derive extensions from SUPPORTED_DOCUMENT_TYPES). Part of saturated MEDIA regex extension cluster with 10+ competing PRs.

@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 duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants