CedarCopilot wants to merge 1 commit into staging from fix/write-document-empty-attachment
Live on prod, no production signal yet
Unable to verify the behavior: no matching writeDocumentTool telemetry was found in production since the deployment, either in OTEL spans or CloudWatch logs. Positive runtime success evidence and tied failure/correlation data are absent.
Libra found 1 production surface on prod but could not judge any of them yet. Libra checks hourly for 3 days after each deploy.
write-document's Gmail-attachment branch was gated on if (input.sourceEmailAttachment), which is truthy for { messageId: '', attachmentId: '' } , present but empty, not a real attachment request."No attachments found on that message", and the real content (e.g. a meeting-prep doc) never got saved.document/upsert write with no attachment involved. The downstream effect: the doc write failing caused the dependent Slack notification to fail too, silently falling back to an email notification instead.input.sourceEmailAttachment?.messageId so an empty/absent messageId is treated as no attachment request, and the write proceeds normally.sourceEmailAttachment: { messageId: '', attachmentId: '' }) on a normal document/upsert write, asserting it now succeeds without touching the Gmail-attachment pathpnpm --filter @zero/server exec vitest run src/mastra/tools/document/__tests__/writeDocumentTool.test.ts , 10/10 passpnpm --filter @zero/server exec tsc --noEmit , clean for the changed file🤖 Generated with Claude Code
https://claude.ai/code/session_01TQPx6BBWdyUWGF7YuvakuV
This PR makes ordinary document writes ignore an empty sourceEmailAttachment.messageId, preventing them from being misrouted through Gmail attachment retrieval.
The behavioral fix appears sound, but the explicit repository requirement against type assertions must be satisfied before merging.
The changed runtime guard correctly handles the reported empty-string input, and the only accepted issue is the regression test’s use of prohibited casts.
Files Needing Attention: apps/server/src/mastra/tools/document/tests/writeDocumentTool.test.ts
| Filename | Overview |
|---|---|
| apps/server/src/mastra/tools/document/writeDocumentTool.ts | Narrows the Gmail attachment branch guard so an empty message ID falls through to normal document writing. |
| apps/server/src/mastra/tools/document/tests/writeDocumentTool.test.ts | Adds focused regression coverage for the empty attachment shape, but bypasses test typing with prohibited assertions. |
### Issue 1
apps/server/src/mastra/tools/document/__tests__/writeDocumentTool.test.ts:333-335
**Test bypasses type checking**
The new regression test uses `as never` twice and asserts the result shape instead of deriving or validating the actual types. This violates the repository directive not to use casts to silence TypeScript errors. The repository requirement must be satisfied before merging by using typed test inputs and context and the inferred execute result.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Reviews (1): Last reviewed commit: "fix(documents): ignore an empty sourceEm..." | Re-trigger Greptile
Greptile also left 1 inline comment on this PR.
| Surface | Requests | Errors | p95 | Users | Verdict |
|---|---|---|---|---|---|
| writeDocumentTool.execute | no baseline → 0 | no baseline → 0 (0%) | not measured | not counted | Unavailable ClickHouse reads are unavailable, so Libra could not measure this surface. |