Conversation
📝 WalkthroughWalkthroughEmpty ChangesFile ID handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/app/files_test.go (1)
675-681: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the attachment-only fallback path.
This test only verifies an empty
fileIdwith noattachmentId, so it exercises the skip path. Add a case with an emptyfileIdand validattachmentIdthat asserts the attachment ID is copied and patched successfully.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/app/files_test.go` around lines 675 - 681, Extend the test around CopyAndUpdateCardFiles to cover a block with an empty fileId and a valid attachmentId, verifying the attachment ID is copied and the corresponding file backend patch succeeds. Keep the existing empty-file-and-attachment skip case, and assert the expected backend interaction and resulting block state for the attachment-only fallback path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@server/app/files_test.go`:
- Around line 675-681: Extend the test around CopyAndUpdateCardFiles to cover a
block with an empty fileId and a valid attachmentId, verifying the attachment ID
is copied and the corresponding file backend patch succeeds. Keep the existing
empty-file-and-attachment skip case, and assert the expected backend interaction
and resulting block state for the attachment-only fallback path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 599ef2c2-38f7-4684-a1d9-6b6565269fb2
📒 Files selected for processing (4)
server/app/files.goserver/app/files_test.goserver/model/block.goserver/model/block_test.go
There was a problem hiding this comment.
I couldn't repro the original issue so I investigated with Claude and apparently it's only reproducible with legacy data:
The fileId validation in baseValidations() was introduced on 22 Jan 2025. Since then, no new block can be saved with fileId = "" through any normal API path. The bug exclusively hits boards created before that validation existed, where a user started (or abandoned) an image/attachment upload and the empty string got persisted.
Summary
Duplicating a board failed with
400 Block ID cannot be emptywhen any image or attachment block had an emptyfileIdorattachmentId. The message came fromValidateFileId("")insideBlock.IsValid()andCopyCardFilesaborting the whole duplicate. Fix by treat an empty file reference as "no file attached"Ticket Link
https://mattermost.atlassian.net/browse/MM-63792
Manual QA
<name> copyappears in the sidebar and opens.Change Impact: 🟡 Medium
Regression Risk: Changes affect shared block validation and board duplication flows, but behavior is narrowly scoped to empty file references and covered by automated tests.
QA Recommendation: Manual QA is recommended for duplicating boards with removed image or attachment files.
Generated by CodeRabbitAI