[Bug]: Page image uploads succeed, but original and thumbnail return 404 Attachment was not found

未关闭
#389 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
半天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
go, sql
领域
api, backend, database

调研方向

Start in internal/repository/attachment_repository.go, where the item download and thumbnail lookups join items and restrict entity_type, so page-scoped rows never match. Compare with internal/services/page_attachment_upload_service.go, which writes EntityType "page", and internal/services/item_attachment_service.go, which OpenItemAttachment calls. Done when a page image's content and thumbnail return 200 for authorised users while unauthorised and unrelated requests still get 404.

由索引模型根据 Issue 内容生成。

描述

fixed-0.9.2
Summary

Page image uploads persist both the original image and its thumbnail, but opening the resulting attachment through the shared attachment binary URLs returns 404 with {"error":{"code":"not_found","message":"Attachment was not found"}}.

This appears to be a mismatch between page-scoped upload metadata and item-only retrieval. The existing binary endpoints call OpenItemAttachment, which intentionally excludes attachment rows where entity_type='page'.

Environment
  • Windshift: self-hosted Linux binary; deployment derived from v0.8.9 with a local SMTP patch. The code paths described were also inspected in the main branch (28 October 2026).
  • AWS EC2, systemd and Nginx reverse proxy.
  • Filesystem storage enabled with --attachment-path /var/lib/windshift/attachments.
  • Uploading a JPEG to a page created both a .jpeg and .thumb.jpg under attachments/pages/5/.
Steps to reproduce
  1. Start Windshift with a writable --attachment-path.
  2. As an authorised user, open a workspace page and upload/insert a JPEG image.
  3. Confirm the upload succeeds and the image and thumbnail exist under the storage root.
  4. Open the embedded image in a new tab (or request the generated /attachments/{id}/content or /thumbnail URL).
  5. Observe a 404 JSON error: Attachment was not found.
Expected

An authorised user with permission to view the owning page can retrieve the original and thumbnail inline. Unauthorised users, or requests for unrelated/nonexistent attachments, continue to receive 404. Existing work-item attachments remain unaffected.
Actual
The upload writes the files, but the binary response returns 404 not_found.

Root-cause analysis
  • internal/services/page_attachment_upload_service.go: UploadPageAttachment records EntityType: "page", ItemID: in.PageID and stores files in a pages// directory.
  • internal/restapi/v2/attachments.go: the shared /attachments/{attachment_id}/content, /download and /thumbnail routes use serveItemAttachment, calling OpenItemAttachment.
  • internal/services/item_attachment_service.go: OpenItemAttachment calls GetItemDownloadRecord / GetItemThumbnailRecord.
  • internal/repository/attachment_repository.go: both item record lookups JOIN items and explicitly restrict entity_type to item-like values. A page-scoped row can therefore never match. The resulting ErrItemAttachmentNotFound maps to the observed JSON 404.
主要语言
Go
星标
421
派生
50
平均合并
17 小时 34 分钟
30 天内合并 PR
80

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Windshiftapp/core 的其他 Issue

查看 Windshiftapp/core 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。