Removing a card attachment silently fails: frontend calls a non-existent OCS route (Deck 1.18.3)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, php
Hướng nghiên cứu
Bắt đầu với src/services/AttachmentApi.js, appinfo/routes.php và lib/Controller/AttachmentOcsController.php, sau đó tái hiện yêu cầu DELETE từ một tệp đính kèm thẻ. Đối chiếu các route và tham số delete, restore và update với các endpoint đã đăng ký, đồng thời xác minh rằng luồng lỗi hiển thị với người dùng. Hoàn tất khi việc xóa tệp đính kèm hoạt động và lỗi yêu cầu không còn biến mất trong im lặng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Removing an attachment from a card does nothing. The action menu stays open, the attachment stays in the list, and no error is shown to the user.
The reason is a mismatch between the OCS route the frontend calls and the route the backend registers.
What the frontend sends (Chrome DevTools, Network tab):
DELETE /ocs/v2.php/apps/deck/api/v1.0/cards/138/attachment/file:1117?boardId=15
Result: 404 Not Found
What the backend registers (appinfo/routes.php, v1.18.3, line 165):
['name' => 'attachment_ocs#delete', 'url' => '/api/v{apiVersion}/cards/{cardId}/attachments/{attachmentId}', 'verb' => 'DELETE'],
Two separate problems:
1. Path: the frontend uses /attachment/ (singular), the route is /attachments/ (plural).
2. Parameters: AttachmentOcsController::delete() expects a numeric attachmentId and a separate type query parameter, but the frontend passes the composite value file:1117 in the path segment.
// lib/Controller/AttachmentOcsController.php, v1.18.3
public function delete(int $cardId, int $attachmentId, string $type = 'file', ?int $boardId = null): DataResponse
The offending frontend code (src/services/AttachmentApi.js, v1.18.3):
async deleteAttachment(attachment, boardId) {
await axios({
method: 'DELETE',
url: this.ocsUrl(`/cards/${attachment.cardId}/attachment/${attachment.type}:${attachment.id}`),
params: {
boardId: boardId ?? null,
},
})
}
I verified both problems on a live instance by patching the shipped bundle:
• DELETE .../cards/165/attachment/file:1126?boardId=17 -- 404, as shipped.
• DELETE .../cards/165/attachments/file:1126?boardId=17 -- 403. The route matches, but (int) "file:1126" becomes 0, so the permission check runs against a non-existent attachment.
• DELETE .../cards/165/attachments/1126?type=file&boardId=17 -- 200, works.
Steps to reproduce
1. Open any card and switch to the Attachments tab.
2. Upload a file, or attach an existing one from Files.
3. Open the ... menu next to the attachment and click "Remove attachment".
Expected behaviour
The attachment is removed from the card. If the request fails, the user sees an error message.
Actual behaviour
Nothing happens. The menu stays open, the attachment remains, and no error is shown. The failure is only visible in the browser's network tab as a 404.
Additional notes
• restoreAttachment() looks affected as well. It sends GET .../cards/{cardId}/attachment/{type}:{id}/restore, while the route is PUT .../cards/{cardId}/attachments/{attachmentId}/restore -- wrong path and wrong verb. I did not test this.
• updateAttachment() builds the same singular path and may have the same problem.
• main looks only partly fixed. AttachmentApi.js on main now uses /attachments/ (plural), but still passes the composite ${type}:${id} in the path segment rather than a numeric id plus a type parameter. Worth checking whether that path actually resolves.
• No error handling. Even once the route is fixed, a failing request should surface a message instead of failing silently. That is what made this hard to diagnose.
• There is also a console error when opening a card with an attachment, which may or may not be connected:
TypeError: Cannot read properties of undefined (reading 'id')
at o.currentCard (deck-main.js)
Suggested fix
async deleteAttachment(attachment, boardId) {
await axios({
method: 'DELETE',
url: this.ocsUrl(`/cards/${attachment.cardId}/attachments/${attachment.id}`),
params: {
type: attachment.type,
boardId: boardId ?? null,
},
})
}
Server configuration
• Nextcloud version: 34.0.3
• Deck version: 1.18.3
• Operating system: Ubuntu 24.04.4 LTS
• Web server: Apache behind Plesk, PHP-FPM
• PHP version: 8.3
• Database: MariaDB 10.11.14
Client configuration
• Browser: Google Chrome
• Operating system: Windows
Reproduced on three independent instances, all running Nextcloud 34 with Deck 1.18.3.
- Ngôn ngữ chính
- JavaScript
- Star
- 1.4k
- Fork
- 358
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 89
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/deck
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
CSV export leaves trailing commas in tags and assigned-user fieldsCó thể đã có người làm @Kumar-s75 đã nhận 40 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Board clone API failure is treated as a successful board responseCó thể đã có người làm @Kumar-s75 đã nhận 40 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nextcloud/deck#8334 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
1. to develop bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nextcloud/deck#8146 · 2 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của nextcloud/deck
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
subhranshudash13-dotcom/Contribo#74 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
ThatGuySam/doesitarm#1114 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
laaielichter/Reverseport#44 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
failed for an unknown reason
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
OpenTermsArchive/contrib-declarations#4148 ·
Maintainer thường phản hồi trong vòng 1 ngày