Skip to content

feat: opt-in binary uploads saved to disk (UPLOAD_SAVE_EXTENSIONS) - #1

Merged
burakbudanur merged 1 commit into
mainfrom
feat/opt-in-binary-uploads
Nov 2, 2026
Merged

burakbudanur merged 1 commit into
mainfrom
feat/opt-in-binary-uploads

Conversation

@burakbudanur

Copy link
Copy Markdown

Description

PDFs and other binary files sent to the bot were refused twice: .pdf is not in the security validator's upload allowlist, and the agentic document handler only accepts UTF-8 text it can inline into the prompt.

  • UPLOAD_SAVE_EXTENSIONS (comma-separated, default empty, so no behaviour change) extends the validator allowlist. In agentic mode, matching files are saved under UPLOAD_SAVE_DIR (default .telegram-uploads, relative to the current working directory) as <UTC timestamp>_<sanitised name>, and Claude gets the saved path instead of the content.
  • The resolved path is refused outside APPROVED_DIRECTORY. UPLOAD_SAVE_DIR must be relative without ..; extensions must match \.[a-z0-9]{1,10}. The 10 MB limit and the other filename checks are unchanged. Classic mode is unchanged.
  • Docs: .env.example, docs/configuration.md, CLAUDE.md; CHANGELOG.md entry.

How it was tested

  • New tests: settings parsing and rejection, validator with and without the extra extensions, upload-name/path safety (../, absolute names, hidden names, symlink escape), and the handler (file saved, path passed to Claude; nothing saved by default).
  • Full suite: 705 passed (excluding tests/unit/test_mcp/test_telegram_server.py, which needs the optional MCP dependency not installed in the test env). flake8 clean; black 25.x / isort 6 formatting.
  • Hand test against the running bot: set UPLOAD_SAVE_EXTENSIONS=.pdf, restart, send a PDF (to be done by the maintainer).

Note

The bot currently running on our machine is the same patch on top of v1.8.0 (commit 54f08ff, branch bquant/v1.8.0-uploads). That branch could not be pushed: its .github/workflows files differ from this fork's main, and the token lacks the workflow scope. This PR is based on the fork's main, so it also includes the two upstream commits after v1.8.0 (overwirehq#236 stop-reason footer, overwirehq#239 CI).

🤖 Generated with Claude Code

PDFs (and any other binary type) sent to the bot were refused twice: the
security validator's upload allowlist has no .pdf, and the agentic document
handler only accepts UTF-8 text it can inline into the prompt.

- UPLOAD_SAVE_EXTENSIONS (default empty, so no behaviour change) extends the
  validator allowlist; in agentic mode matching files are saved under
  UPLOAD_SAVE_DIR (default .telegram-uploads, relative to the current working
  directory) as <UTC timestamp>_<sanitised name>, and Claude gets the path.
- The resolved path is refused outside APPROVED_DIRECTORY; UPLOAD_SAVE_DIR must
  be relative without '..'. Size limit and other filename checks unchanged.
- Tests for settings parsing, validator, path safety and the handler; docs in
  .env.example, docs/configuration.md, CLAUDE.md; CHANGELOG entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@burakbudanur
burakbudanur merged commit 1ed6b87 into main Nov 2, 2026
@burakbudanur
burakbudanur deleted the feat/opt-in-binary-uploads branch November 2, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant