Repository navigation
fix(logging): report dropped file log records - #132672
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 3:44 AM ET / 07:44 UTC. ClawSweeper reviewWhat this changesThe PR adds bounded, per-file redacted stderr warnings when file-log records are dropped, including synchronous diagnostics while pending records are drained during process exit. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessThe patch addresses a real silent logging failure at the file-transport owner and the supplied real-path traces cover both normal append failure and forced exit. No introduced correctness defect was found; retain this PR for normal exact-head CI and maintainer merge review. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s logger serializes application records into a bounded file queue. The file transport appends those records to the configured log target and now reports append failures to stderr without recursively using the failed file transport. flowchart LR
A[Application log record] --> B[Logger transport callback]
B --> C[Bounded file queue]
C --> D[File append]
D -->|success| E[Configured log file]
D -->|failure| F[Per-file failure state]
F --> G[Redacted stderr diagnostic]
G --> H[Operator action]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +49, Tests +132. Total +181 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the warning state at the file-transport owner, with one redacted sink shared by asynchronous writes and forced-exit draining; the bounded state and shared sink justify the added production code. Do we have a high-confidence way to reproduce the issue? Yes. The reviewed exact-base and exact-head directory-target traces exercise the production logger path: the baseline drops the record with no warning, while the head emits one redacted warning and preserves a control-file write. Is this the best way to solve the issue? Yes. The file transport is the sole owner that knows whether the real append succeeded, so recording the failure streak there avoids downstream inference and prevents recursive logging through the failed target. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f1d2c5b91f80. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
813ed5e to
2a69e58
Compare
|
Thanks @Alix-007! Proof: A real directory log target dropped its record on current main without a warning. The repaired exact head emitted one redacted warning, preserved the valid control record, and kept the warning visible through piped stderr during forced process exit.
Example
|
Report dropped file-log records at the transport owner so append failures no longer disappear silently. - Bound and isolate warning state per log target. - Redact configured paths before direct stderr output. - Write forced-exit warnings synchronously so piped diagnostics survive. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
File-log append failures dropped records while
flushLogger()still resolved. Operators received no warning that the configured log was incomplete.This PR is AI-assisted. The implementation and proof were reviewed by maintainers.
Root Cause
The file transport caught and discarded errors from both the asynchronous appender and the forced-exit synchronous appender. Only this transport can observe whether the real append succeeded.
Fix
The file transport now writes a direct stderr warning for the first dropped record in each file's continuous failure streak. It clears only that file's warning state after a successful append. It also bounds retained failure paths and emits one saturation warning when the bound is reached. Forced-exit drains use a synchronous stderr write so piped diagnostics survive
process.exit().The direct stderr sink avoids
console.warn()recursion into the same failed file transport. If stderr itself throws, the transport continues and retries the warning after the next dropped record. The warning tells the operator to check that the target is a writable regular file.Queue ordering, retry policy, flush settlement, and process-exit rescue behavior are unchanged.
Production Shape
src/logging/logger-file-transport.ts.Evidence
The same production entry was run with a real directory as the invalid log target and a real file as the control target.
Exact current main
c5c6199bc8592c988738480164a2950b920f6b39:{"failedTargetType":"directory","failedRecordPersisted":false,"flushResolved":true,"appendFailureDiagnostic":false,"warningCount":0,"controlPersisted":true}Exact repaired head
2a69e5853dffc46c7642fd8c10ffa73fc4094ebf:{"failedTargetType":"directory","failedRecordPersisted":false,"flushResolved":true,"appendFailureDiagnostic":true,"warningCount":1,"pathSecretRedacted":true,"controlPersisted":true}Observed warning:
Exact repaired-head forced-exit trace with piped stderr and a deferred stream write:
{"sha":"2a69e5853dffc46c7642fd8c10ffa73fc4094ebf","exitStatus":0,"stderrPiped":true,"streamWriteDeferredPastExit":true,"appendFailureDiagnostic":true,"pathSecretRedacted":true,"warningCount":1}Validation
oxfmt --checkand type-awareoxlint: passed.git diff --check: passed.Integration Checks
@openclaw/fs-safe0.5.6 propagates non-file and append errors to the transport catch.ClawSweeper