feat(line): add file message type download support#27787
Conversation
Greptile SummaryAdded LINE file message support (PDF, PPTX, etc.) and fixed sandbox media access by migrating from Key changes:
Architecture improvement: Confidence Score: 5/5
Last reviewed commit: 8987da8 |
c1d9415 to
8987da8
Compare
|
Nice improvement moving LINE downloads into One follow-up: |
8987da8 to
692f8e2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 692f8e23d1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const ext = getExtensionForContentType(contentType); | ||
| // Save to ~/.openclaw/media/inbound/ so sandbox can access the file. | ||
| // Previously saved to /tmp/openclaw/ which was outside the sandbox root. | ||
| const saved = await saveMediaBuffer(buffer, undefined, "inbound", maxBytes); |
There was a problem hiding this comment.
Pass LINE file metadata into media storage
This call always passes undefined content type (and no filename) into saveMediaBuffer, so LINE file uploads lose their original MIME/extension hints and rely only on byte sniffing. For common cases like plain text/CSV (often not sniffed) or ZIP-container office files (sniffed generically), the saved attachment can end up as unknown or generic type; later normalization falls back to application/octet-stream, and file extraction logic treats that as binary and skips parsing. As a result, some LINE file messages are downloaded but still unusable to the agent; pass available LINE file metadata (e.g., filename and content type/header when present) through this path.
Useful? React with 👍 / 👎.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
692f8e2 to
20e2252
Compare
897f5ac to
21c35d9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21c35d9150
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const filePath = buildRandomTempFilePath({ prefix: "line-media", extension: ext }); | ||
| // Save to ~/.openclaw/media/inbound/ so sandbox can access the file. | ||
| // Previously saved to /tmp/openclaw/ which was outside the sandbox root. | ||
| const saved = await saveMediaBuffer(buffer, contentType, "inbound", maxBytes, originalFilename); |
There was a problem hiding this comment.
Preserve extension-based MIME hints for LINE file uploads
Passing originalFilename into saveMediaBuffer here still drops the filename extension during MIME resolution, because saveMediaBuffer/detectMime only use buffer+header unless a filePath hint is provided. For ZIP-container Office uploads (.docx/.xlsx/.pptx), detectMime can collapse to application/zip (its own comment calls out the XLSX-vs-ZIP case), and media-understanding/apply.ts treats ZIP as binary and skips text extraction, so these LINE file messages remain downloaded but unusable to the agent.
Useful? React with 👍 / 👎.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
31119eb to
c458134
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c458134d01
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| message.type === "image" || | ||
| message.type === "video" || | ||
| message.type === "audio" || | ||
| message.type === "file" | ||
| ) { |
There was a problem hiding this comment.
Save LINE file downloads under media directory
Adding message.type === "file" here routes LINE file events through downloadLineMedia, but in this commit that helper still writes to buildRandomTempFilePath (src/line/download.ts:42), i.e. /tmp/openclaw/... rather than the inbound media store. In sandboxed runs, stageSandboxMedia only stages local attachments from getMediaDir() and explicitly skips paths outside that root (src/auto-reply/reply/stage-sandbox-media.ts:106-115), so these newly-downloaded file attachments are dropped before the agent can read them.
Useful? React with 👍 / 👎.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LINE's file message type (PDFs, documents, etc.) was not handled by the inbound media download logic. This adds "file" to the existing image/video/audio check so file attachments are downloaded and passed to the agent. The previous version of this PR also included media sandbox path fixes and MIME detection improvements, but upstream has since landed equivalent changes (buildRandomTempFilePath + detectContentType). This commit now only contains the file type addition. Closes openclaw#27722 ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
downloadLineMedia() was saving to /tmp/openclaw/ via buildRandomTempFilePath(), but stageSandboxMedia() only allows files under ~/.openclaw/media/. This meant all LINE media downloads (image/video/audio, and now file) were inaccessible to sandboxed agents. Switch to saveMediaBuffer() (matching Telegram/Discord/Signal), extract Content-Type from LINE API response headers, and pass message.fileName for file-type messages to improve MIME detection. ✍️ Author: Claude Code (Reizan Container) with osabe
03f5420 to
0ec4545
Compare
|
Superseded by #32546, which consolidates this LINE workstream into the merged canonical fix set. |
LINE's
filemessage type (PDFs, documents, etc.) is not handled by the inbound media download logic — onlyimage,video, andaudioare checked. This means file attachments sent via LINE are silently dropped.Additionally,
downloadLineMedia()saves all media to/tmp/openclaw/viabuildRandomTempFilePath(), butstageSandboxMedia()only allows files under~/.openclaw/media/. This means sandboxed agents cannot access any LINE-downloaded media (image/video/audio/file).Changes
src/line/bot-handlers.ts: addmessage.type === "file"to the media download condition; passmessage.fileNamefor file-type messagessrc/line/download.ts: switch frombuildRandomTempFilePath()+fs.writeFiletosaveMediaBuffer()(matching Telegram/Discord/Signal); extract Content-Type from LINE API response headers viagetMessageContentWithHttpInfo; addoriginalFilenameparametersrc/line/download.test.ts: update tests forsaveMediaBuffermock-based approachCloses #27722
✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)