nextcloud / nextcloud/deck

Deleting/updating file attachments fails with 404 — frontend calls singular attachment/{type}:{id} but OCS route is plural attachments/{id}

Open Beginner friendly
#8,146 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop bug
Dominant language
JavaScript
Stars
1.4k
Forks
354
Avg merge
1d 10h
Merged PRs (30d)
43

Description

Describe the bug
Removing a file attachment (a file shared from Files, type: file) from a card via the sidebar (⋯ → Remove attachment) does nothing. The DELETE request returns HTTP 404 / OCS statuscode: 998 ("Invalid query"). The same mismatch affects updating and restoring attachments.

Steps to reproduce

Add a file to a card via "Share from Files" (creates a share_type 12 attachment).
Open the card, ⋯ on the attachment → Remove attachment.
Nothing happens; the Network tab shows a failed DELETE.

Actual request (fails):
DELETE /ocs/v2.php/apps/deck/api/v1.0/cards/52/attachment/file:198?boardId=7
→ 404, {"ocs":{"meta":{"status":"failure","statuscode":998,"message":"Invalid query, ..."}}}

Root cause
The frontend AttachmentApi builds the URL with singular attachment/ and a composite type🆔
// src/services/attachment.js (as shipped in js/deck-main.js)
async deleteAttachment(attachment, boardId) {
await axios({ method: 'DELETE',
url: this.ocsUrl(/cards/${attachment.cardId}/attachment/${attachment.type}:${attachment.id}),
params: { boardId: boardId ?? null } })
}
// updateAttachment() and restoreAttachment() use the same singular attachment/${type}:${id} scheme

But the OCS routes register delete/update/restore under plural attachments/{attachmentId} with type as a separate parameter:
// appinfo/routes.php (ocs)
['name' => 'attachment_ocs#delete', 'url' => '/api/v{apiVersion}/cards/{cardId}/attachments/{attachmentId}', 'verb' => 'DELETE'],
// AttachmentOcsController::delete(int $cardId, int $attachmentId, string $type = 'file', ?int $boardId = null)

So the singular path matches no OCS route → 998/404. (createAttachment POST /cards/{cardId}/attachment and getAll /cards/{cardId}/attachments both match fine — only delete/update/restore are inconsistent.)

Confirmed working call (proves the backend is fine, only the frontend URL is wrong):
DELETE /ocs/v2.php/apps/deck/api/v1.0/cards/52/attachments/198?type=file&boardId=7
→ 200 OK (share removed, source file kept)

Suggested fix
Align the frontend AttachmentApi delete/update/restore to /cards/${cardId}/attachments/${attachment.id} and pass type via params (matching the OCS controller). The shipped 1.18.2 JS bundle appears out of sync with the OCS routes.

Server configuration

Nextcloud: 34.0.1
Deck: 1.18.2 (files verified against the official signature.json — unmodified)
DB: MySQL · PHP 8.x · nginx (YunoHost)
Browser: Chrome 149

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/services/attachment.js and compare deleteAttachment(), updateAttachment(), and restoreAttachment() with the OCS routes in appinfo/routes.php and AttachmentOcsController. Verify the request path and parameters against the confirmed working DELETE call, then exercise removing, updating, and restoring a file attachment to confirm all three operations succeed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
api, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.