Skip to content

fix(feishu): persist durable attachment reference on inbound message (#108534) - #108588

Closed
SymbolStar wants to merge 1 commit into
openclaw:mainfrom
SymbolStar:fix/issue-108534
Closed

SymbolStar wants to merge 1 commit into
openclaw:mainfrom
SymbolStar:fix/issue-108534

Conversation

@SymbolStar

Copy link
Copy Markdown
Contributor

Fixes #108534

What Problem This Solves

Fixes an issue where a Feishu user uploading a file to the bot loses the durable local reference to the file after the inline preview is truncated. In the reporter's scenario a 411 KB SQL file appears in the agent-facing message body only as a <media:document> placeholder (with the file name), so a follow-up turn has no reliable way to locate the downloaded file without scanning the shared ~/.openclaw/media/inbound directory.

Why This Change Was Made

Root cause: buildFeishuAgentBody in extensions/feishu/src/bot-agent-body.ts builds the persisted body from ctx.content and quoted content only. The resolved mediaList (which already carries the exact downloaded path, contentType, and placeholder kind) is passed to toInboundMediaFacts for the turn-level media payload but was never surfaced in the message body itself.

Minimal fix: thread mediaList into buildFeishuAgentBody and append a small trailing <attachments> block listing each attachment's path, kind (derived from the existing <media:*> placeholder), and optional contentType. The inline <media:...> preview, the FeishuMediaInfo / toInboundMediaFacts shape, and the media directory / dedupe layout are all unchanged. Scope is intentionally narrower than #19330 (shared inbound isolation).

User Impact

Agent turns triggered by Feishu file/image/audio/video messages now have a stable, machine-readable pointer (path:) to each attachment in the persisted message body. Follow-up turns can locate the exact downloaded file without directory scanning, even when the inline preview was truncated.

Evidence

New unit tests in bot.helpers.test.ts cover both the populated <attachments> block and the empty-mediaList no-op case. Existing buildFeishuAgentBody tests continue to pass because the new block is only emitted when at least one media entry has a resolved path.

Local pnpm --filter run was skipped (no pnpm on this machine); CI will validate.

…penclaw#108534)

When a Feishu file/image/audio/video message is downloaded, buildFeishuAgentBody previously only carried the inline <media:...> placeholder (or truncated preview) into the agent-facing body. The FeishuMediaInfo entries produced alongside toInboundMediaFacts — including the exact local path under ~/.openclaw/media/inbound — were dropped from the persisted message body.

Reporter scenario: a 411 KB SQL file was truncated inline; a follow-up turn had no durable reference and had to scan the shared inbound media directory to guess which file belonged to the message.

Fix: append a small <attachments> block listing each downloaded attachment's path, kind, and contentType (when available). Inline preview and toInboundMediaFacts shape are unchanged. Scope is intentionally narrower than openclaw#19330 (shared inbound isolation).
@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: S labels Jul 16, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 31, 2026, 8:47 AM ET / 12:47 UTC.

ClawSweeper review

What this changes

The branch passes Feishu’s resolved inbound media list into the agent-body formatter and appends each downloaded attachment’s local path, kind, and content type to the message text.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 8 items remain

Keep this PR open for human review. The branch has not advanced since the prior ClawSweeper cycle, which already identified an unresolved choice between duplicating attachment paths in message text and using the existing structured-media context path; the supplied material does not establish which path current main now persists across follow-up turns. It also still lacks contributor-supplied after-fix Feishu runtime proof.

Priority: P1
Reviewed head: 54bf476b3398f642fbf670528489fddb05b41766
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and tested at formatter level, but it lacks real behavior proof and leaves a material canonical-media and security-boundary concern unresolved.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR provides formatter unit tests but no after-fix Feishu run showing a truncated upload, persisted durable reference, and successful follow-up access; add redacted transcript, terminal/live output, recording, or runtime logs before merge. 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: The PR provides formatter unit tests but no after-fix Feishu run showing a truncated upload, persisted durable reference, and successful follow-up access; add redacted transcript, terminal/live output, recording, or runtime logs before merge. 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 4 items Unresolved prior review finding: The previous completed ClawSweeper review on the same head identified a P1 concern: the PR should use the existing structured media persistence path rather than add a parallel text representation. The supplied context shows no later contributor commit addressing that finding.
Patch scope: The branch modifies the Feishu agent-body formatter, its caller, and formatter tests; it appends raw local attachment paths to persisted message text whenever resolved media has a path.
Proof gap: The PR body supplies formatter unit-test claims only and explicitly says the local test run was skipped. No supplied after-fix Feishu transcript, redacted runtime log, recording, or live output demonstrates that a later turn receives and successfully uses the durable reference.
Findings 1 actionable finding [P1] Use the canonical structured media path
Security Needs attention Avoid persisting shared inbound paths as a second authority: The new attachment block copies local inbound paths into agent-visible message text; with shared inbound storage, that can make attachment discovery available through transcript context rather than the canonical media boundary.

How this fits together

Feishu receives an inbound message, downloads any attachment, and constructs agent context for the resulting turn. That context feeds the agent/session transcript and determines whether a later turn can identify the same downloaded file without scanning shared inbound storage.

flowchart LR
  A[Feishu inbound message] --> B[Attachment download]
  B --> C[Resolved media records]
  C --> D[Agent turn context]
  D --> E[Session transcript]
  E --> F[Later agent follow-up]
  F --> G[Attachment access decision]
Loading

Decision needed

Question Recommendation
Should Feishu follow-up attachment access be implemented by persisting canonical structured media facts through session context, or is duplicating absolute inbound paths into transcript text an approved durable contract? Use canonical media facts: Carry the existing resolved media record or managed reference through the session/follow-up boundary and avoid a second transcript-text authority.

Why: The PR changes the durable representation of attachment authority while the linked open issue identifies shared inbound storage as a privacy boundary; this requires an explicit owner decision rather than a formatter-only merge judgment.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR provides formatter unit tests but no after-fix Feishu run showing a truncated upload, persisted durable reference, and successful follow-up access; add redacted transcript, terminal/live output, recording, or runtime logs before merge. 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.
  • Use the canonical structured media path (P1) - The formatter adds a second persisted attachment representation even though resolved media is already carried as structured turn data. The prior review identified this exact unresolved boundary; retain one canonical record through follow-up context instead of making transcript text a parallel authority for file identity.
  • Resolve security concern: Avoid persisting shared inbound paths as a second authority - The new attachment block copies local inbound paths into agent-visible message text; with shared inbound storage, that can make attachment discovery available through transcript context rather than the canonical media boundary.
  • Resolve merge risk (P1) - The PR may create a parallel durable-reference format in persisted text instead of carrying the canonical structured media record through the session boundary, allowing the two representations to drift.
  • Resolve merge risk (P1) - Appending shared inbound absolute paths to model-visible transcript text may widen cross-agent attachment discovery while the broader isolation issue remains open.
  • Resolve merge risk (P1) - The branch is behind main; refresh the comparison before merge, but stale-base status alone is not evidence that a merge would remove current-main behavior.
  • Complete next step (P2) - A maintainer must choose the durable attachment authority and trust boundary before an automated repair can safely change the Feishu session path.

Findings

  • [P1] Use the canonical structured media path — extensions/feishu/src/bot-agent-body.ts:25-39
  • [medium] Avoid persisting shared inbound paths as a second authority — extensions/feishu/src/bot-agent-body.ts:29
Agent review details

Security

Needs attention: The patch introduces a model-visible persisted copy of absolute inbound file paths, so the shared-media trust boundary needs explicit review before merge.

PR surface

Source +32, Tests +40. Total +72 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 34 2 +32
Tests 1 40 0 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 74 2 +72

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Carry one canonical attachment reference (recommended)
    Revise the change so later turns consume the existing structured media representation rather than a separately formatted path block, then add focused follow-up coverage and real Feishu proof.
  2. Approve the transcript contract explicitly
    If raw attachment paths in persisted agent text are intentional, document the trust and upgrade boundary and accept the shared-storage exposure deliberately.
  3. Pause for the media-isolation design
    Close or pause this narrow formatter approach if the broader per-agent inbound-media isolation decision must determine the durable reference format first.

Technical review

Best possible solution:

Preserve one canonical structured attachment reference from Feishu ingestion through follow-up session context, with an owner-approved policy for any model-visible path or managed-media reference, then prove the large-document follow-up flow in a redacted real Feishu setup.

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

No high-confidence current-main reproduction is established in the supplied evidence. The proposed formatter path is source-reproducible from the branch, but the required comparison against current-main structured-media persistence and a real Feishu follow-up run is missing.

Is this the best way to solve the issue?

No. The formatter block is a plausible local workaround, but the prior review identified a potentially canonical structured-media path; current evidence does not show that duplicating raw paths into transcript text is the narrowest maintainable fix.

Full review comments:

  • [P1] Use the canonical structured media path — extensions/feishu/src/bot-agent-body.ts:25-39
    The formatter adds a second persisted attachment representation even though resolved media is already carried as structured turn data. The prior review identified this exact unresolved boundary; retain one canonical record through follow-up context instead of making transcript text a parallel authority for file identity.
    Confidence: 0.73

Overall correctness: patch is incorrect
Overall confidence: 0.68

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5cd00cfbaa05.

Labels

Label justifications:

  • P1: A Feishu document follow-up can lose the deterministic reference needed to process the original upload, affecting an active channel workflow.
  • merge-risk: 🚨 session-state: The change alters what attachment identity is persisted in agent-facing message and transcript context for later turns.
  • merge-risk: 🚨 security-boundary: The patch places local shared inbound-storage paths into model-visible persisted message text while a linked issue tracks cross-agent media isolation.
  • 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: The PR provides formatter unit tests but no after-fix Feishu run showing a truncated upload, persisted durable reference, and successful follow-up access; add redacted transcript, terminal/live output, recording, or runtime logs before merge. 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] Avoid persisting shared inbound paths as a second authority — extensions/feishu/src/bot-agent-body.ts:29
    The new attachment block copies local inbound paths into agent-visible message text; with shared inbound storage, that can make attachment discovery available through transcript context rather than the canonical media boundary.
    Confidence: 0.72

What I checked:

  • Unresolved prior review finding: The previous completed ClawSweeper review on the same head identified a P1 concern: the PR should use the existing structured media persistence path rather than add a parallel text representation. The supplied context shows no later contributor commit addressing that finding. (extensions/feishu/src/bot-agent-body.ts:17, 54bf476b3398)
  • Patch scope: The branch modifies the Feishu agent-body formatter, its caller, and formatter tests; it appends raw local attachment paths to persisted message text whenever resolved media has a path. (extensions/feishu/src/bot-agent-body.ts:17, 54bf476b3398)
  • Proof gap: The PR body supplies formatter unit-test claims only and explicitly says the local test run was skipped. No supplied after-fix Feishu transcript, redacted runtime log, recording, or live output demonstrates that a later turn receives and successfully uses the durable reference. (54bf476b3398)
  • Related security boundary: The linked open report describes the broader shared inbound-media directory as a cross-agent privacy problem. Persisting absolute paths into transcript text needs an explicit owner-boundary decision so it does not become a second source of attachment authority. (extensions/feishu/src/bot-agent-body.ts:25, 54bf476b3398)

Likely related people:

  • joeyzenghuan: Recent Feishu release work addressed topic-session continuity, making this a relevant adjacent routing and transcript-context contact rather than an attribution of this PR’s defect. (role: adjacent Feishu session-context contributor; confidence: low; files: extensions/feishu/src/bot.ts)
  • harjothkhara: The related gateway media-dispatch PR analyzed canonical media representations and Feishu media delivery, so this person is a useful technical routing candidate for the structured-media boundary. (role: adjacent media-path contributor; confidence: low; commits: 388921b9342e; files: extensions/feishu/src/bot.ts)

Rank-up moves

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

  • Show a redacted Feishu upload and later follow-up turn using the durable reference, with private paths and identifiers removed.
  • Resolve the canonical structured-media-versus-transcript-path representation with the relevant Feishu/session owner.
  • Rebase onto current main and rerun the focused Feishu tests after the owner-boundary choice is implemented.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-16T04:21:17.603Z sha 54bf476 :: needs real behavior proof before merge. :: [P1] Use the existing structured media persistence path

@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 Aug 28, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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: S 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.

[Bug]: Feishu document attachments lose their durable local reference after inline truncation

1 participant