Skip to content

fix(zalouser): files and photos sent over Zalo reach the agent only as a link - #159253

Closed
ceo633 wants to merge 2 commits into
openclaw:mainfrom
ceo633:fix/zalouser-inbound-attachments
Closed

ceo633 wants to merge 2 commits into
openclaw:mainfrom
ceo633:fix/zalouser-inbound-attachments

Conversation

@ceo633

@ceo633 ceo633 commented Sep 26, 2026

Copy link
Copy Markdown

Closes #159249

What Problem This Solves

Fixes: files, photos and videos that users send over Zalo personal account (zalouser) reach the agent only as a file name and a CDN link, so the agent cannot read them.

User Impact

User impact: a PDF, photo or video sent over zalouser is saved to the media store and passed to the agent as inbound media, the same way as on Telegram and the Zalo Bot channel. If the download fails, the turn still runs and the agent is told the attachment is unavailable.

Why This Change Was Made

  • Normalization now reads the attachment the way zca-js delivers it: share.file → document (original file name from title), chat.photo → image, chat.video.msg → video. Only https URLs are used. Link previews and plain text are ignored.
  • The monitor downloads with the existing runtime saveRemoteMedia helper (SSRF guard, requireHttps, the account mediaMaxBytes, header/idle/total timeouts, original file name), and passes the result to buildContext as media. The download runs only after access and mention gating, so dropped messages never fetch anything.
  • A download can take up to two minutes, so access is re-checked after it finishes. A sender revoked in the meantime is still dropped.
  • On failure it uses formatInboundMediaUnavailableText, matching extensions/zalo.
  • No Zalo session cookies are sent: the Zalo CDN URLs download without them.

Evidence

  • monitor.group-gating.test.ts: 31/31 pass on this branch (rebased on main). Five new cases cover: download plus media facts, the failure notice, no download when mention gating drops the message, and a sender revoked during the download (with a not-revoked control). Fault injection: removing the post-download re-check turns the revoked case red while the control stays green; changing the notice text turns the failure case red.
  • New normalization cases in zalo-quote-metadata.test.ts use real payload shapes (file, photo, video, link preview, plain text, http, invalid URL). On my Windows machine every test in that file fails in teardown with EBUSY (unlinking sqlite), including the untouched tests, so I also ran extractZaloInboundAttachment directly: 8/8 pass, and it goes red when the mapping is broken. CI on Linux should run the file normally.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test: 0 errors. oxfmt --check: clean. oxlint: only the existing max-lines warning on monitor.group-gating.test.ts, which was already over the limit (1078 lines) before this change.
  • Packaging check: scripts/plugin-npm-publish.sh --pack of unmodified v2026.9.5 is byte-identical to the published npm tarball. The patched pack differs only by this change.
  • Live: on a production install (2026.9.5), PDFs and RAR files sent by users over Zalo were never saved. The same Zalo CDN URLs returned 206 for a ranged GET without cookies. Gap: I could not run the patched plugin live, because a locally built plugin does not get trusted plugin state (the credentials store), so it cannot log in. That is expected, and it is why this is proposed upstream.

Related: #84924 (photos only; closed for inactivity).

🤖 Generated with Claude Code

…o inbound media

Inbound Zalo attachments (share.file, chat.photo, chat.video.msg) reached the
agent only as the file name plus a Zalo CDN link. Extract the https attachment
URL during normalization and, after access and mention gating, download it with
the runtime saveRemoteMedia helper (account mediaMaxBytes, requireHttps,
header/idle/total timeouts) and pass it to buildContext as inbound media. A
failed download keeps the turn and tells the agent the attachment is
unavailable, matching the Zalo Bot channel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The download can take up to two minutes; re-resolve the route-bound access
decision afterwards so a revocation in the meantime still drops the turn.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: zalouser Channel integration: zalouser size: M labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 26, 2026, 8:19 PM ET / September 27, 2026, 00:19 UTC.

ClawSweeper review

What this changes

The Zalo personal-account plugin now downloads inbound files, photos, and videos into OpenClaw media storage and passes them to agent turns, with normalization and gating tests.

Merge readiness

⛔ Blocked before merge - 7 items remain

Current main still lacks inbound attachment media for Zalo personal accounts, so this is useful work. The branch needs fixes for retained media after access revocation, document filenames, and the test line cap; it also lacks an after-fix run through a real Zalo account.

Priority: P1
Reviewed head: 3d24c3f6395388ffccfe579e0b5b812beeddd6e4

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The plugin-level approach is useful, but after-fix real behavior is unproven and the patch has actionable metadata, revocation, and test-ratchet defects.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: Authority-chain proof required: The changed Zalo monitor is tested with mocked messages and a mocked media downloader, including a revoked-sender dispatch check, but no final filesystem check. The contributor reports live pre-fix Zalo failures and a CDN range request, and explicitly could not run the patched plugin through an authenticated Zalo account; the older PR's screenshots do not prove this head. Show an after-fix real inbound file or photo turn and a revoked-sender case with no retained file, with private details redacted. Updating the PR body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review. No stored data-model contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Authority-chain proof required: The changed Zalo monitor is tested with mocked messages and a mocked media downloader, including a revoked-sender dispatch check, but no final filesystem check. The contributor reports live pre-fix Zalo failures and a CDN range request, and explicitly could not run the patched plugin through an authenticated Zalo account; the older PR's screenshots do not prove this head. Show an after-fix real inbound file or photo turn and a revoked-sender case with no retained file, with private details redacted. Updating the PR body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review. No stored data-model contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Current main lacks attachment media: The current-main Zalo normalizer still flattens attachment content to text; the monitor builds the agent context without media.
Introduced media path: The introduced patch calls the shared media downloader and adds its result to the agent context after admission checks.
Revocation after publication: The sender-access recheck follows saveRemoteMedia, which publishes the file before returning; the denied branch drops the turn without discarding that saved file.
Findings 3 actionable findings [P2] Discard downloaded media when sender access is revoked
[P2] Prefer Zalo's document title over the CDN filename
[P2] Split the added attachment tests below the line cap
Security Needs attention Media publication precedes revocation check: The final filesystem write can complete during a two-minute download before the sender's authority is rechecked. The denied path suppresses dispatch but does not settle the new stored artifact.

How this fits together

The Zalo personal-account plugin receives messages from zca-js, checks sender and group access, and builds the agent turn. This change adds a guarded media download between admission and dispatch.

flowchart LR
  A[Zalo message] --> B[Attachment normalization]
  B --> C[Access and mention checks]
  C --> D[Guarded media download]
  D --> E[Access recheck]
  E --> F[Agent turn or drop]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Authority-chain proof required: The changed Zalo monitor is tested with mocked messages and a mocked media downloader, including a revoked-sender dispatch check, but no final filesystem check. The contributor reports live pre-fix Zalo failures and a CDN range request, and explicitly could not run the patched plugin through an authenticated Zalo account; the older PR's screenshots do not prove this head. Show an after-fix real inbound file or photo turn and a revoked-sender case with no retained file, with private details redacted. Updating the PR body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review. No stored data-model contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Discard downloaded media when sender access is revoked (P2) - The new download publishes a file before the post-download access check. When the pairing store revokes the sender during that await, this branch drops the turn but leaves the saved attachment behind; the new test checks dispatch only. Settle or discard that file on rejection and verify the final filesystem effect for the revoked case.
  • Prefer Zalo's document title over the CDN filename (P2) - For shared files, attachment.fileName comes from Zalo's original title, but saved.fileName takes precedence here. The shared downloader normally derives that value from content disposition or the final CDN URL because this call supplies no filePathHint, so an opaque CDN basename can replace the user's filename in the agent media fact. The test mock gives both names the same value and misses this case.
  • Split the added attachment tests below the line cap (P2) - Adding this block grows the existing suite beyond the configured 1,000 counted-line cap, and the PR's baseline-ratchets check failed. Move the attachment cases into a coherent sibling test file with shared setup without weakening the assertions or raising the baseline.
  • Resolve security concern: Media publication precedes revocation check - The final filesystem write can complete during a two-minute download before the sender's authority is rechecked. The denied path suppresses dispatch but does not settle the new stored artifact.
  • Resolve merge risk (P1) - A sender revoked during the download can leave their attachment in the media store even though the agent turn is dropped; final filesystem-effect cleanup and forbidden-sender proof remain unresolved.
  • Complete next step (P2) - Fix the revocation cleanup, filename precedence, and test line cap; then add redacted after-fix Zalo and forbidden-sender final-effect proof before merge.

Findings

  • [P2] Discard downloaded media when sender access is revoked — extensions/zalouser/src/monitor.ts:591-595
  • [P2] Prefer Zalo's document title over the CDN filename — extensions/zalouser/src/monitor.ts:193
  • [P2] Split the added attachment tests below the line cap — extensions/zalouser/src/monitor.group-gating.test.ts:1052
  • [medium] Media publication precedes revocation check — extensions/zalouser/src/monitor.ts:591
Agent review details

Security

Needs attention: The diff adds no dependency or supply-chain change, but a revoked sender's newly downloaded attachment can remain published after the turn is denied.

PR surface

Source +125, Tests +215. Total +340 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 128 3 +125
Tests 2 216 1 +215
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 344 4 +340

Review metrics

Metric Value Why it matters
Code growth production +125 lines, tests +215 lines The implementation is bounded to the plugin, while most test growth lands in a suite governed by a 1,000-line cap.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #159249
Summary: The open issue reports the same inbound Zalo media failure and this PR is its candidate fix; the older closed photo PR overlaps only the photo portion and was not merged.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Settle revoked downloads (recommended)
    Discard a downloaded file when current sender authority rejects the turn, and prove the rejected case leaves no published media.
  2. Pause this branch
    Hold the PR if the plugin cannot make media publication safe across revocation within its existing runtime contract.

Technical review

Best possible solution:

Keep the guarded download in the Zalo plugin, preserve Zalo's original document name, and make media publication safe across access revocation; demonstrate the patched inbound flow with a real account.

Do we have a high-confidence way to reproduce the issue?

Yes from source: current main converts the reported attachment payload to text and does not pass media to the agent context. The live pre-fix report supports that path; this read-only review did not execute it.

Is this the best way to solve the issue?

Partly. Reusing the guarded media downloader is the narrow owner-level approach, but the branch must preserve document metadata and settle a saved file when sender access is revoked.

Full review comments:

  • [P2] Discard downloaded media when sender access is revoked — extensions/zalouser/src/monitor.ts:591-595
    The new download publishes a file before the post-download access check. When the pairing store revokes the sender during that await, this branch drops the turn but leaves the saved attachment behind; the new test checks dispatch only. Settle or discard that file on rejection and verify the final filesystem effect for the revoked case.
    Confidence: 0.88
  • [P2] Prefer Zalo's document title over the CDN filename — extensions/zalouser/src/monitor.ts:193
    For shared files, attachment.fileName comes from Zalo's original title, but saved.fileName takes precedence here. The shared downloader normally derives that value from content disposition or the final CDN URL because this call supplies no filePathHint, so an opaque CDN basename can replace the user's filename in the agent media fact. The test mock gives both names the same value and misses this case.
    Confidence: 0.92
  • [P2] Split the added attachment tests below the line cap — extensions/zalouser/src/monitor.group-gating.test.ts:1052
    Adding this block grows the existing suite beyond the configured 1,000 counted-line cap, and the PR's baseline-ratchets check failed. Move the attachment cases into a coherent sibling test file with shared setup without weakening the assertions or raising the baseline.
    Confidence: 0.85

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8d3f946089b5.

Labels

Label changes:

  • add P1: The reported defect prevents agents from reading files and photos in a live Zalo channel workflow.
  • add merge-risk: 🚨 security-boundary: The new filesystem write can finish before the patch's post-download sender revocation check.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: The changed Zalo monitor is tested with mocked messages and a mocked media downloader, including a revoked-sender dispatch check, but no final filesystem check. The contributor reports live pre-fix Zalo failures and a CDN range request, and explicitly could not run the patched plugin through an authenticated Zalo account; the older PR's screenshots do not prove this head. Show an after-fix real inbound file or photo turn and a revoked-sender case with no retained file, with private details redacted. Updating the PR body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review. No stored data-model contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The reported defect prevents agents from reading files and photos in a live Zalo channel workflow.
  • merge-risk: 🚨 security-boundary: The new filesystem write can finish before the patch's post-download sender revocation check.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: The changed Zalo monitor is tested with mocked messages and a mocked media downloader, including a revoked-sender dispatch check, but no final filesystem check. The contributor reports live pre-fix Zalo failures and a CDN range request, and explicitly could not run the patched plugin through an authenticated Zalo account; the older PR's screenshots do not prove this head. Show an after-fix real inbound file or photo turn and a revoked-sender case with no retained file, with private details redacted. Updating the PR body should trigger re-review; otherwise ask a maintainer to comment @clawsweeper re-review. No stored data-model contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Media publication precedes revocation check — extensions/zalouser/src/monitor.ts:591
    The final filesystem write can complete during a two-minute download before the sender's authority is rechecked. The denied path suppresses dispatch but does not settle the new stored artifact.
    Confidence: 0.86

What I checked:

  • Current main lacks attachment media: The current-main Zalo normalizer still flattens attachment content to text; the monitor builds the agent context without media. (extensions/zalouser/src/zalo-js.ts:153, 8d3f946089b5)
  • Introduced media path: The introduced patch calls the shared media downloader and adds its result to the agent context after admission checks. (extensions/zalouser/src/monitor.ts:178, 3d24c3f63953)
  • Revocation after publication: The sender-access recheck follows saveRemoteMedia, which publishes the file before returning; the denied branch drops the turn without discarding that saved file. (extensions/zalouser/src/monitor.ts:591, 3d24c3f63953)
  • Original filename precedence: The PR supplies Zalo's title as originalFilename but prefers saved.fileName in the agent fact. The shared downloader derives saved.fileName from content disposition or the final CDN URL unless filePathHint is supplied. (extensions/zalouser/src/monitor.ts:193, 3d24c3f63953)
  • Line-cap growth: The added attachment cases extend the existing test file from 1,038 to 1,197 physical lines. A read-only count of nonblank, noncomment lines rises from approximately 974 to 1,118; the configured test cap is 1,000 and the CI baseline-ratchets check failed. (extensions/zalouser/src/monitor.group-gating.test.ts:1052, 3d24c3f63953)
  • Proof scope: The contributor reports a live failure on version 2026.9.5, passing branch tests, and a cookie-free CDN range request, but explicitly says the patched plugin could not be run with the account. The inspected screenshots belong to the older, closed and unmerged photo PR, not this head. (3d24c3f63953)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Gazali: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Show a redacted after-fix Zalo file or photo reaching the agent through the patched plugin.
  • Add final-effect proof that a revoked sender gets no agent dispatch and leaves no published attachment.
  • Preserve the original document title and split the attachment tests under the line cap.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 11, 2026
roboclaw-bot added a commit that referenced this pull request Nov 4, 2026
Carry received Zalo Personal files, photos, and videos through the shared guarded media store into agent input. Preserve original document names, admission and command checks, cancellation, CDN/HTTPS/private-network/redirect/size/MIME limits, and rejected-file cleanup.

Synthetic durable-ingress regressions prove the missing handoff red on main and green with the repair, including authorization and cleanup controls. Independent review and exact-head CI cover the final candidate.

Supersedes #159253, thanks @ceo633.
Closes #159249.
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @ceo633 for reporting this and working on the repair! Fixed in #192608, including readable inbound media, original filenames, guarded downloads, and cleanup after revocation or cancellation. Closing this superseded PR.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…aw#192608)

Carry received Zalo Personal files, photos, and videos through the shared guarded media store into agent input. Preserve original document names, admission and command checks, cancellation, CDN/HTTPS/private-network/redirect/size/MIME limits, and rejected-file cleanup.

Synthetic durable-ingress regressions prove the missing handoff red on main and green with the repair, including authorization and cleanup controls. Independent review and exact-head CI cover the final candidate.

Supersedes openclaw#159253, thanks @ceo633.
Closes openclaw#159249.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: zalouser Channel integration: zalouser merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zalouser: inbound files, photos and videos reach the agent only as a CDN link, never as media

3 participants