Skip to content

Gateway should not treat MEDIA examples or missing files as attachments #16434

@qwertysc

Description

@qwertysc

Bug Description

Gateway response post-processing treats every MEDIA:<path> token as a real attachment directive, even when the token appears inside fenced code blocks, inline code, grep output, or other examples. It also attempts to send non-existent paths, producing noisy Failed to send media: File not found warnings.

Steps to Reproduce

  1. Send a gateway response that contains a code snippet or test output with a literal MEDIA:/tmp/missing.png example.
  2. Let the platform adapter post-process the response.
  3. Inspect errors.log / gateway logs.

Expected Behavior

  • Literal MEDIA: examples inside code should remain text.
  • Non-existent MEDIA: paths should not be attempted as attachments.
  • Real existing local files referenced by MEDIA: should still be delivered and removed from text.

Actual Behavior

The adapter attempts delivery for example/missing paths and logs warnings such as:

[Feishu] Failed to send media (.png): Image file not found: /tmp/img.png

Impact

This creates noisy warning/error logs during code review, grep output, or tests that include MEDIA: examples, making real delivery failures harder to spot.

Proposed Fix

Update BasePlatformAdapter.extract_media() to:

  • ignore matches inside fenced code blocks and inline code,
  • validate that expanded local paths exist before returning them for delivery,
  • remove only accepted delivery tags from the outgoing text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliverytype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions