Skip to content

fix(gateway): accept html and generic documents - #51880

Open
riccodecarvalho wants to merge 1 commit into
NousResearch:mainfrom
riccodecarvalho:fix/gateway-html-documents
Open

fix(gateway): accept html and generic documents#51880
riccodecarvalho wants to merge 1 commit into
NousResearch:mainfrom
riccodecarvalho:fix/gateway-html-documents

Conversation

@riccodecarvalho

Copy link
Copy Markdown

Summary

  • accept .html/.htm and .tsv as first-class document types with canonical MIME types
  • keep generic document uploads accepted instead of forcing users to zip/rename uncommon files
  • make text-document context notes explicit that inline content is optional and the saved file should be read when exact source matters
  • cover Telegram observed-group document handling and document-context behavior with tests

Verification

  • python -m pytest tests/gateway/test_document_cache.py tests/gateway/test_document_context_note.py tests/gateway/test_telegram_group_gating.py -q -o 'addopts='

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jun 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related / competing OPEN cluster for inbound document acceptance: #12702 (adds .html/.htm to the allowlist) and #40584 (accepts + inlines small HTML Telegram uploads). This PR is the broadest of the three (generic documents + .tsv + Telegram observed-group handling). Flagging for a maintainer to pick the canonical approach — the allowlist-only and telegram-only PRs may be subsumed by this one.

@teknium1 teknium1 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.

Thanks for the gateway coverage. Current main already accepts the PR's generic-document path, but a narrow useful correction remains.

Problems

  • Generic authorized-file acceptance is already on main: 4314d451 changed gateway/platforms/base.py:1701-1714 to cache non-media attachments regardless of extension, and Telegram already accepts them at plugins/platforms/telegram/adapter.py:7994-8005.
  • The added .html / .htm / .tsv entries in the static expected-extension test are catalog snapshots; tests/gateway/test_document_cache.py's new cache_media_bytes behavior test is the stronger contract.

Suggested changes

  • Re-scope salvage to the still-needed pieces: canonical MIME mappings, normalized doc_mime, and the context-note correction. gateway/run.py:2074-2079 currently says every text/* attachment was included, while Telegram intentionally skips inline content above 100 KiB or after UTF-8 decoding fails (plugins/platforms/telegram/adapter.py:8013-8027).
  • Keep the behavioral regression test and avoid extending the static extension snapshot.

Automated hermes-sweeper review.

[
".pdf",
".md",
".html",

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.

The behavior test added below is the regression contract for HTML routing. Adding individual extensions to this static list turns it into a catalog snapshot; please rely on the behavior test rather than expanding this enumeration.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026

@GottZ GottZ 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.

This was generated by AI during triage.

Summary

Two open PRs address adjacent inbound-document classification problems. #51880 adds canonical HTML/TSV MIME handling and corrects misleading document context, while #55777 detects extensionless UTF-8 text and carries explicit inline-state through the Telegram path.

Related pull requests

  • #51880 related — (+84/-20) — keep open, narrow before merge: generic-document acceptance is already present on main, but the diff still provides useful canonical MIME mappings for HTML/TSV, normalized Telegram MIME selection, a truthful optional-inline context note, and behavioral coverage. This follows the keep_open review on #51880; remove the redundant generic-acceptance framing and static extension snapshot.
  • #55777 related — (+124/-23) — keep open as a separate follow-up: the diff addresses the distinct extensionless-upload cause by conservatively sniffing UTF-8 text, routing the primary Telegram ingress through cache_media_bytes, and tracking whether text was actually inlined. This follows the keep_open review on #55777; its per-attachment inline-state is more precise than #51880's globally optional wording but requires rebasing around the narrower #51880 change.

Suggested consolidation

Merge #51880 after narrowing it to canonical MIME mappings, normalized doc_mime use, truthful context-note behavior, and behavioral tests. Keep #55777 open and rebase it afterward for the distinct extensionless-text classification and explicit inline-state work; neither PR should be closed as a duplicate.

Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 27 kB of PR diffs, 4 kB of issue/PR text, 5 kB of discussion (4 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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 platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants