Skip to content

fix(telegram): resolve local Bot API container file paths against trustedLocalFileRoots [AI-assisted] - #91984

Merged
steipete merged 3 commits into
openclaw:mainfrom
Dizesales:fix-telegram-local-bot-api-file-paths
Jul 4, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
Dizesales:fix-telegram-local-bot-api-file-paths

Conversation

@Dizesales

@Dizesales Dizesales commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #100092

What Problem This Solves

Fixes an issue where users of a Dockerized self-hosted Telegram Bot API would have inbound documents reach the agent as placeholders without bytes when getFile returned the container-absolute /var/lib/telegram-bot-api/... path but OpenClaw saw the same volume at a different trusted host path.

The contributor reproduced this on a production OpenClaw gateway with aiogram/telegram-bot-api:latest, TELEGRAM_LOCAL=1, and a host volume configured in trustedLocalFileRoots. Before the fix, the message reached the agent but media/inbound stayed empty.

Why This Change Was Made

The maintainer rebuild maps only the official local Bot API absolute-path contract into operator-configured trusted roots. It supports data-root and per-token-root mounts, including the upstream colon-to-tilde token-directory behavior, while keeping ordinary relative paths on the existing HTTP download path.

Every local read still goes through fsRoot().read(). Missing mapped candidates may try the next bounded mount shape; policy, symlink, permission, and size failures remain visible instead of being swallowed. Unknown absolute roots, empty segments, NULs, and dot segments are rejected.

No new config is added. The existing trustedLocalFileRoots documentation and generated channel metadata now explain the container-volume mapping.

User Impact

Operators can mount a self-hosted Telegram Bot API data directory at a different host path and still receive the actual attachment bytes. Existing cloud Bot API and relative-path downloads are unchanged, and configured trusted roots remain the filesystem authority.

Evidence

  • Contributor live proof: production OpenClaw 2026.6.1 on Ubuntu with Node 22.22.2 and aiogram/telegram-bot-api:latest; a 499 KB zip materialized under media/inbound after the path mapping was applied as a dist-level hotfix.
  • Official dependency contract: tdlib/telegram-bot-api documents absolute file_path values in --local mode; upstream Client.cpp at 0a9e5696ba149c99bedf972f040d2e28776a8a4f confirms the per-token directory and colon-to-tilde behavior.
  • Focused local proof: node scripts/run-vitest.mjs extensions/telegram/src/bot.media.stickers-and-fragments.e2e.test.ts extensions/telegram/src/bot/delivery.resolve-media-retry.test.ts — 2 files, 47 tests passed, including a real fs-safe host-volume read.
  • Blacksmith Testbox tbx_01kwqczycnebqzzhqbdecsy2c4: the same 47 focused tests passed; check:changed and check:docs passed.
  • node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check passed after refreshing generated metadata.
  • Fresh Codex autoreview: no accepted or actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/28719419537

Proof gap: the maintainer did not move a shared Telegram credential from the cloud Bot API into a dedicated local Bot API during review. The live server proof is the contributor's production run; the rebuilt source patch is additionally covered by actual-host-filesystem E2E and Testbox proof.


AI-assisted (Claude Code on the original contribution; maintainer rebuild and review with Codex).

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 10, 2026
@Dizesales
Dizesales force-pushed the fix-telegram-local-bot-api-file-paths branch from c7a96c2 to c673c34 Compare June 10, 2026 16:23
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 353e3bf7c31bfc87e1284d0aa0d451da15326322, but the PR head is now bf99cef19fc63a9c7917f980bb11453fdfa71676. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (1 earlier review cycle)
  • reviewed 2026-06-22T00:19:55.705Z sha c673c34ee95c6be410f6a9cc90d11d8b8adcf98f :: needs changes before merge. :: [P2] Preserve trusted-root read failures

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 19, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 19, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 20, 2026
@steipete steipete self-assigned this Jul 4, 2026
AiLucasdz and others added 2 commits July 4, 2026 21:53
…stedLocalFileRoots

When the self-hosted telegram-bot-api server runs with --local inside a
container, getFile returns absolute file_path values rooted at the
container data dir (/var/lib/telegram-bot-api/...). The host process
mounts that volume at a different path, so the absolute path never
matches a trustedLocalFileRoots entry and inbound media fails to
materialize (messages reach the agent as bare <media:document>
placeholders without bytes).

Map container-absolute paths back to relative candidates and resolve
them under each trusted root, trying both with and without the
per-token directory segment the local server uses. Relative file_path
values are now also resolved against trusted roots before falling back
to the HTTP file endpoint, which keeps large-file (>20MB) local-mode
downloads working.

Path traversal protections: candidates are normalized, NUL bytes and
dot-segments are rejected, and reads stay behind the trusted-roots
file-access sandbox.

AI-assisted (Claude Code), validated with targeted vitest run.

Co-Authored-By: Claude Fable 5 <[email protected]>

Co-Authored-By: Dizesales <[email protected]>
@steipete
steipete force-pushed the fix-telegram-local-bot-api-file-paths branch from c673c34 to 353e3bf Compare July 4, 2026 20:53
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Jul 4, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 4, 2026
@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Land-ready maintainer rebuild completed on exact head bf99cef19fc63a9c7917f980bb11453fdfa71676.

  • Narrowed the implementation to the official local Bot API absolute-path contract; ordinary relative paths keep the existing HTTP path.
  • Preserved fs-safe policy, permission, symlink, and size errors while allowing only missing mapped candidates to continue.
  • Added data-root, token-root, colon-to-tilde, traversal, non-missing-error, and actual host-filesystem E2E coverage.
  • Updated Telegram docs, config hints, generated bundled-channel metadata, and changelog attribution.
  • Focused local proof: 2 files / 47 tests passed.
  • Blacksmith Testbox tbx_01kwqczycnebqzzhqbdecsy2c4: 47 focused tests, check:changed, and check:docs passed.
  • Generated metadata check passed.
  • Fresh Codex autoreview: no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/28719419537 — passed.

Live proof: the contributor reproduced and fixed the path against a production OpenClaw gateway plus aiogram/telegram-bot-api:latest; a 499 KB zip materialized under media/inbound. Maintainer review did not move a shared cloud Bot API credential into a dedicated local server, so the rebuilt source path is additionally backed by real-filesystem E2E and Testbox proof.

@steipete
steipete merged commit ff58d23 into openclaw:main Jul 4, 2026
107 of 117 checks passed
@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 5, 2026
…stedLocalFileRoots [AI-assisted] (openclaw#91984)

* fix(telegram): resolve local Bot API container file paths against trustedLocalFileRoots

When the self-hosted telegram-bot-api server runs with --local inside a
container, getFile returns absolute file_path values rooted at the
container data dir (/var/lib/telegram-bot-api/...). The host process
mounts that volume at a different path, so the absolute path never
matches a trustedLocalFileRoots entry and inbound media fails to
materialize (messages reach the agent as bare <media:document>
placeholders without bytes).

Map container-absolute paths back to relative candidates and resolve
them under each trusted root, trying both with and without the
per-token directory segment the local server uses. Relative file_path
values are now also resolved against trusted roots before falling back
to the HTTP file endpoint, which keeps large-file (>20MB) local-mode
downloads working.

Path traversal protections: candidates are normalized, NUL bytes and
dot-segments are rejected, and reads stay behind the trusted-roots
file-access sandbox.

AI-assisted (Claude Code), validated with targeted vitest run.

Co-Authored-By: Claude Fable 5 <[email protected]>

Co-Authored-By: Dizesales <[email protected]>

* fix(telegram): map local Bot API container media paths

Co-authored-by: Lucas Magalhaes <[email protected]>

* chore(config): refresh channel metadata

---------

Co-authored-by: Lucas Magalhaes <[email protected]>
Co-authored-by: Dizesales <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants