BookStackApp/BookStack · error · NotFoundException

errors.attachment_not_found

Error message

errors.attachment_not_found

What it means

NotFoundException rethrown in AttachmentController::get when findVisibleByIdOrFail cannot resolve the page the attachment is uploaded to, meaning the attachment exists but its parent page is not visible (deleted or restricted) to the requesting user. The translated errors.attachment_not_found message hides this detail.

Source

Thrown at app/Uploads/Controllers/AttachmentController.php:222

        return response()->json(['message' => trans('entities.attachments_order_updated')]);
    }

    /**
     * Get an attachment from storage.
     *
     * @throws FileNotFoundException
     * @throws NotFoundException
     */
    public function get(Request $request, string $attachmentId)
    {
        /** @var Attachment $attachment */
        $attachment = Attachment::query()->findOrFail($attachmentId);

        try {
            $page = $this->pageQueries->findVisibleByIdOrFail($attachment->uploaded_to);
        } catch (NotFoundException $exception) {
            throw new NotFoundException(trans('errors.attachment_not_found'));
        }

        if ($attachment->external) {
            $url = (new UrlFilter($attachment->path))->clean();
            return redirect($url);
        }

        $fileName = $attachment->getFileName();
        $attachmentStream = $this->attachmentService->streamAttachmentFromStorage($attachment);
        $attachmentSize = $this->attachmentService->getAttachmentFileSize($attachment);

        if ($request->input('open') === 'true') {
            return $this->createDownload()->streamedInline($attachmentStream, $fileName, $attachmentSize);
        }

        return $this->createDownload()->streamedDirectly($attachmentStream, $fileName, $attachmentSize);
    }

View on GitHub (pinned to 18f8469a1c)

Solutions

  1. Verify the parent page still exists and has not been deleted
  2. Check page/role permissions so the requesting user can view the parent page
  3. If the attachment is orphaned, remove it or re-upload it to a valid page
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at app/Uploads/Controllers/AttachmentController.php:222 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02). Data as JSON: /api/errors/eb374bc290cd5d31. Report an issue: GitHub.