Repository navigation
fix(feishu): log message content JSON parse failures instead of silently swallowing - #107947
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 1:07 PM ET / 17:07 UTC. Summary PR surface: Source +7, Tests +47. Total +54 across 2 files. Reproducibility: yes. source-reproducible. A malformed Feishu body reaches the JSON.parse catch on current main and returns raw content without any diagnostic; the branch regression test exercises that public message-fetch path. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the centralized metadata-only diagnostic after refreshing the branch onto current main and obtaining green exact-head Feishu tests, lint, type, and required CI gates. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible. A malformed Feishu body reaches the JSON.parse catch on current main and returns raw content without any diagnostic; the branch regression test exercises that public message-fetch path. Is this the best way to solve the issue? Yes. Logging once inside the shared parser is the narrowest maintainable fix because both direct-message reads and thread-history items use it; moving diagnostics into individual callers would duplicate policy and risk drift. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8a8706cb5d04. Label changesLabel justifications:
Evidence reviewedPR surface: Source +7, Tests +47. Total +54 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (12 earlier review cycles; latest 8 shown)
|
68f60fd to
f664786
Compare
|
@clawsweeper re-review Addressed rank-up / CI on head
This should clear the PR-caused |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
f664786 to
849d4cc
Compare
…tly swallowing Replace formatErrorMessage(err) with safe metadata-only logging in parseFeishuMessageContent to prevent potential message content leaks through V8 JSON.parse error messages. Changes: - Remove formatErrorMessage import (security: V8 JSON.parse errors can include input content in the message) - Log only msgType and optional messageId (safe metadata) when parse fails, never the exception message or raw content - Add assertion that raw content is NOT present in the log output - Pass messageId through to enable richer diagnostics The raw content is still preserved as the function return value (existing fallback behavior).
849d4cc to
273268e
Compare
|
@clawsweeper re-review |
|
@clawsweeper re-review Updated Evidence section with:
|
The test 'logs a safe diagnostic (not raw content) when message content
is not valid JSON' was declared after the closing brace of
describe('getMessageFeishu'), so it did not inherit that suite's fixture
setup and reset hooks (beforeEach/afterAll). Move it inside the suite
so it benefits from the shared mock reset and cleanup.
Fixes ClawSweeper P2: 'Keep the parse-failure test inside the fetch suite'
|
@clawsweeper re-review Addressed both P1 items:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Added the requested production dist runtime proof to the PR body Evidence section:
|
|
@clawsweeper re-review |
|
Merged via squash.
|
* origin/main: fix: CJK replies are silently dropped instead of recovered when the model skips message(action=send) (openclaw#115556) fix(gateway): stop managed crash loops for pending agent DB migrations (openclaw#115631) fix(plugins): validate constrained empty config schemas (openclaw#109569) fix(cli-runner): scope bundle-MCP cleanup to the run's session, not the process-wide loopback server (openclaw#110251) fix(feishu): log message content JSON parse failures instead of silently swallowing (openclaw#107947) docs(vision,agents): layer calibration, interface-on-demand, telemetry opt-in, whole-document guidance rules
* origin/main: fix: CJK replies are silently dropped instead of recovered when the model skips message(action=send) (openclaw#115556) fix(gateway): stop managed crash loops for pending agent DB migrations (openclaw#115631) fix(plugins): validate constrained empty config schemas (openclaw#109569) fix(cli-runner): scope bundle-MCP cleanup to the run's session, not the process-wide loopback server (openclaw#110251) fix(feishu): log message content JSON parse failures instead of silently swallowing (openclaw#107947) docs(vision,agents): layer calibration, interface-on-demand, telemetry opt-in, whole-document guidance rules fix(memory): preserve Windows session ownership (openclaw#115851) fix(compaction): drop context-engine fallback on codex ownership skip (openclaw#114155) (openclaw#115666) fix(msteams): ignore blank certificate settings (openclaw#109112)
…tly swallowing (openclaw#107947) * fix(feishu): log message content JSON parse failures instead of silently swallowing Replace formatErrorMessage(err) with safe metadata-only logging in parseFeishuMessageContent to prevent potential message content leaks through V8 JSON.parse error messages. Changes: - Remove formatErrorMessage import (security: V8 JSON.parse errors can include input content in the message) - Log only msgType and optional messageId (safe metadata) when parse fails, never the exception message or raw content - Add assertion that raw content is NOT present in the log output - Pass messageId through to enable richer diagnostics The raw content is still preserved as the function return value (existing fallback behavior). * fix(feishu): move parse-failure test into getMessageFeishu suite The test 'logs a safe diagnostic (not raw content) when message content is not valid JSON' was declared after the closing brace of describe('getMessageFeishu'), so it did not inherit that suite's fixture setup and reset hooks (beforeEach/afterAll). Move it inside the suite so it benefits from the shared mock reset and cleanup. Fixes ClawSweeper P2: 'Keep the parse-failure test inside the fetch suite' --------- Co-authored-by: Peter Steinberger <[email protected]>
* origin/main: fix: CJK replies are silently dropped instead of recovered when the model skips message(action=send) (openclaw#115556) fix(gateway): stop managed crash loops for pending agent DB migrations (openclaw#115631) fix(plugins): validate constrained empty config schemas (openclaw#109569) fix(cli-runner): scope bundle-MCP cleanup to the run's session, not the process-wide loopback server (openclaw#110251) fix(feishu): log message content JSON parse failures instead of silently swallowing (openclaw#107947) docs(vision,agents): layer calibration, interface-on-demand, telemetry opt-in, whole-document guidance rules fix(memory): preserve Windows session ownership (openclaw#115851) fix(compaction): drop context-engine fallback on codex ownership skip (openclaw#114155) (openclaw#115666) fix(msteams): ignore blank certificate settings (openclaw#109112)
What Problem This Solves
parseFeishuMessageContentused an emptycatch {}that silently swallowedJSON.parsefailures. The prior fix addedformatErrorMessage(err)to the log, but V8JSON.parseerror messages can include the malformed input content — risking message content leakage in verbose logs.Why This Change Was Made
Security:
formatErrorMessage(err)performs pattern-based redaction only, and does not guarantee removal of arbitrary user message content from V8 error messages. A malformed Feishu message body could leak to operator logs.The fix replaces the exception-derived log text with safe metadata (message type, message ID) while preserving the raw-content fallback.
User Impact
feishu message content parse failed for text message (id: om_xxx)— never the exception message or raw content. Callers still receive the raw content string as fallback.Code Changes
send.tsparseFeishuMessageContentmessageId?: stringparameter for richer diagnosticscatchblockformatErrorMessage(err)— logs onlymsgType+messageIdparseFeishuMessageItemitem.message_idthrough to the parse functionformatErrorMessagefromerror-runtimeBefore (unsafe):
After (safe):
send.test.tslogs a safe diagnostic (not raw content) when message content is not valid JSONmockLogVerboseis called with safe metadatamockLogVerboseis NOT called with raw content{bad json}Evidence
Head SHA:
085013da12dBase:
77f9da5461d1. Real Feishu API Connectivity (Live)
Feishu API reachable — tenant token granted, bot "future的智能助手" active.
2. Exact-HEAD Unit Tests (Full Verbose Output)
3. Security 5-Payload Matrix (Direct Code Path Execution)
The exact
parseFeishuMessageContentcode path tested with 5 malicious payloads — none leak to the log sink:Result: All 5 payloads produce only
"[VERBOSE] feishu message content parse failed for {msgType} message (id: {messageId})"— the raw content is returned to the caller but never reaches the log sink.4. Edge Case Verification
"[VERBOSE] feishu message content parse failed for text message""[VERBOSE] ... for post message (id: om_100)""[VERBOSE] ... for interactive message (id: om_101)"""{"text":"hello"}5. Production Dist Runtime Proof (Not Vitest, Not Mocked)
The PR code is confirmed in the production compiled dist (
dist/send-*.js). ThelogVerbosefunction is loaded from the real productiondist/globals-*.jsmodule via direct Node.jsimport()— no Vitest, no test runner, no mock interception. This is the same module resolution and code path a running OpenClaw gateway executes.6. Diff Summary
7. CI Status
Security/boundary checks all pass. The
build-artifacts,check-lint, andcheck-test-typesfailures on the latest push are infrastructure gaps (PR is 700+ commits behindmain; a rebase onto currentmainwill resolve them). The key proof gateReal behavior proofpassed. Full gates includingopenclaw/ci-gaterequire an up-to-date base after rebase.Tests: 24/24 passed
Security: 5/5 payloads contain no content leakage
Production dist: PR code confirmed in
dist/send-BhWmP0Qp.jsReview