fix(feishu): auto-convert local image path text to image message in outbound#29264
Conversation
Greptile SummaryAdds auto-detection of local image paths in text messages and routes them to image upload instead of sending as plain text.
Confidence Score: 3/5
Last reviewed commit: b18cf02 |
extensions/feishu/src/outbound.ts
Outdated
| if (!fs.existsSync(raw)) return null; | ||
| if (!fs.statSync(raw).isFile()) return null; |
There was a problem hiding this comment.
Race condition: if file is deleted between existsSync and statSync, this will throw an uncaught error.
| if (!fs.existsSync(raw)) return null; | |
| if (!fs.statSync(raw).isFile()) return null; | |
| try { | |
| const stats = fs.statSync(raw); | |
| if (!stats.isFile()) return null; | |
| } catch { | |
| return null; | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/outbound.ts
Line: 25-26
Comment:
Race condition: if file is deleted between `existsSync` and `statSync`, this will throw an uncaught error.
```suggestion
try {
const stats = fs.statSync(raw);
if (!stats.isFile()) return null;
} catch {
return null;
}
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b18cf02223
ℹ️ 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 hasWhitespace = /\s/.test(raw); | ||
| if (hasWhitespace) return null; |
There was a problem hiding this comment.
Handle local image paths that contain spaces
The new auto-conversion path exits early on any whitespace, so valid local image paths like /Users/.../My File.png are never converted and still leak as plain text. This is a real behavior gap because the codebase already treats space-containing absolute paths as valid media inputs (e.g., src/media/parse.test.ts covers /Users/pete/My File.png), so common screenshot-style filenames won’t benefit from this hotfix.
Useful? React with 👍 / 👎.
- Add try-catch around fs.statSync to handle file deletion between existsSync and statSync - Fix oxfmt formatting issues
6e66b9d to
14cad1e
Compare
|
PR #29264 - fix(feishu): auto-convert local image path text to image message in outbound (#29264) Merged via squash.
Thanks @paceyw! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14cad1e14a
ℹ️ 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".
| mediaUrl: localImagePath, | ||
| accountId: accountId ?? undefined, | ||
| }); |
There was a problem hiding this comment.
Forward mediaLocalRoots in sendText auto-conversion
The new sendText auto-conversion path calls sendMediaFeishu without forwarding mediaLocalRoots, unlike the normal sendMedia branch. In contexts where outbound delivery provides scoped roots (for example agent workspace files), loadWebMedia will evaluate the path against default roots and reject common workspace-* paths, causing this conversion to fail and fall back to sending the raw file path text. That means the hotfix silently does not work for trusted local image paths produced in scoped workspaces.
Useful? React with 👍 / 👎.
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit 2fcfe04)
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit 2fcfe04)
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit 2fcfe04)
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…utbound (openclaw#29264) thanks @paceyw Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: paceyw <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit 0e4c24e)
Problem
When upstream agent output accidentally contains a local image path string, Feishu outbound
sendTextsends it as plain text, so users see a local file path instead of an image.Root Cause
No compatibility conversion exists in Feishu outbound text path. Only
sendMediapath handles upload + image send.Fix (Scheme A)
In
extensions/feishu/src/outbound.ts:normalizePossibleLocalImagePath(text)guardsendText, detect path-like local image payload and route tosendMediaFeishusendMessageFeishuon failureWhy this approach
Validation checklist
Notes
This addresses runtime behavior where local file path text could leak to Feishu chat. It does not replace long-term protocol governance (structured image output), which can be handled in a follow-up.