fix: skip file download errors in search instead of aborting#69
fix: skip file download errors in search instead of aborting#69AmethystLiang merged 9 commits intostablyai:mainfrom
Conversation
A 401/404 on a single file attachment (deleted file, no read
permission) would throw through downloadSlackFile and kill the
entire search operation. The message-read path already handled
this gracefully via downloadMessageFiles' per-file try/catch,
but search-messages and search-files called downloadSlackFile
directly with no error handling.
Wrap each downloadSlackFile call in try/catch { continue } so
failed downloads are skipped and remaining results still return.
|
This is the Codex review. Once addressed, will merge the PR for you. High
Medium
No tests cover these search download/error paths, so the regression risk here is higher than usual. |
Introduce SlackDownloadError and tryDownloadSlackFile wrapper that distinguishes network/HTTP errors (caught) from disk/write errors (propagated). Failed downloads now produce DownloadResult objects that flow through toCompactMessage, preserving file metadata so content-type filtering works correctly even when downloads fail.
|
Addressed both issues (note: this increases scope): High — failed downloads dropping messages from content-type–filtered search results The root cause was that Medium — swallowing all exceptions silently Introduced Added 18 tests covering the download wrapper, Example search output with a failed download{
"messages": [
{
"ts": "1710000000.000001",
"author": { "user_id": "U12345" },
"content": "Here's the screenshot",
"files": [
{
"mimetype": "image/png",
"path": "/tmp/agent-slack-downloads/F0001.png"
}
]
},
{
"ts": "1710000000.000002",
"author": { "user_id": "U67890" },
"content": "Check this attachment",
"files": [
{
"mimetype": "image/jpeg",
"error": "Failed to download file (401)"
}
]
}
]
} |
AmethystLiang
left a comment
There was a problem hiding this comment.
Reviewed latest branch state locally after the follow-up fixes. Full test suite and typecheck pass, and the download-error contract/docs are now aligned.
Problem
When a Slack file attachment returns a 401 (no read permission) or 404 (deleted),
downloadSlackFilethrows.message get,message list) handles this gracefully —downloadMessageFileswraps each download in a try/catch, logs a warning, and continues.search-messages,search-files) calldownloadSlackFiledirectly with no error handling, so a single inaccessible attachment kills the entire search operation.This commonly happens with:
Fix
Wrap each
downloadSlackFilecall in search-messages and search-files withtry { … } catch { continue }src/slack/for tolerable errors (e.g.channels.ts,messages.ts,search-messages.tsmessage enrichment).Notes
canvas.ts) is intentionally left unchanged — there, the file download IS the primary operation, so a failure should still surface as an error.downloadSlackFile,downloadOptionalSlackFilewhich handles the try-catch on that side, but this doesn't look like the pattern in this repo