feat(discord): allow_any_attachment config to accept arbitrary file types - #27245
Merged
Conversation
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.
Summary
Discord users can now upload arbitrary file types (e.g.
.wav,.bin, custom extensions) instead of only the built-inSUPPORTED_DOCUMENT_TYPESallowlist (PDF / text family / zip / office). Default off — historical behavior preserved.What was broken
Today the gateway drops any attachment whose extension isn't in the allowlist. The file gets logged as "Unsupported document type" and discarded before the agent ever sees it. A user trying to upload a
.wavfor the agent to inspect (e.g.ffprobeit via terminal) had no path forward.Changes
gateway/platforms/discord.py: two new adapter helpers (_discord_allow_any_attachment,_discord_max_attachment_bytes); document branch widened to cache unknown types asapplication/octet-streamwhen the flag is on;msg_typeclassifier flips toDOCUMENTfor unknown types when allowed.hermes_cli/config.py:discord.allow_any_attachment(defaultfalse) anddiscord.max_attachment_bytes(default 32 MiB;0= unlimited) added toDEFAULT_CONFIG.website/docs/user-guide/messaging/discord.md: env-var table rows + a "Receiving Arbitrary File Types" prose section.website/docs/reference/environment-variables.md:DISCORD_ALLOW_ANY_ATTACHMENT+DISCORD_MAX_ATTACHMENT_BYTESrows.tests/gateway/test_discord_document_handling.py: 9 new tests (TestAllowAnyAttachment) covering default-off, flag-on cache, MIME fallback to octet-stream, size cap, unlimited mode, allowlisted-doc-still-works, env fallback, config-wins-over-env, garbage-value handling.Behavior with the flag on
~/.hermes/cache/documents/.DOCUMENT-typed event withapplication/octet-streamMIME —gateway/run.pyalready handles that and emits the "[The user sent a document … saved at ]" context note with sandbox-translated paths viato_agent_visible_cache_path()(Docker / Modal safe)..txt/.md/.log) keep their existing 100 KiB inline behavior.Scope
Discord-only by deliberate choice. Telegram has a hard 20 MB API limit and Slack has its own caps; extending this flag to them is a separate follow-up if/when asked for.
Test plan
scripts/run_tests.sh tests/gateway/test_discord_document_handling.py tests/gateway/test_document_cache.py— 42/42 passed.scripts/run_tests.sh tests/gateway/ tests/hermes_cli/test_config.py tests/hermes_cli/test_config_validation.py tests/hermes_cli/test_config_drift.py— 5592 passed, 7 skipped, 0 failed.How to use
Or via env:
DISCORD_ALLOW_ANY_ATTACHMENT=true.