Skip to content

fix: return 404 not 500 when stored file gone from disk - #3734

Merged
kolaente merged 3 commits into
mainfrom
fix-missing-avatar-file
Sep 4, 2026
Merged

fix: return 404 not 500 when stored file gone from disk#3734
kolaente merged 3 commits into
mainfrom
fix-missing-avatar-file

Conversation

@tink-bot

@tink-bot tink-bot commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

DB row point at file. Blob gone from disk. LoadFileByID hand back raw storage path error, error handler turn into 500, Sentry eat noise (API-OSS-50). Broken install, not server bug — now ErrFileDoesNotExist with new error code 4034, so 404.

Callers that matched on *fs.PathError (files.Dump, user data export) switched to files.IsErrFileDoesNotExist.

How to verify

  1. Upload an avatar for a user and set the avatar provider to "upload".
  2. Delete the corresponding blob from the file storage directory (files.basepath, e.g. /var/lib/vikunja/files/<file id>). Do not request the avatar before deleting it, otherwise the cached copy is served.
  3. Request GET /api/v1/avatar/<username>.
  4. Expected: HTTP 404 with error code 4034 and the message "The file does not exist."
    Before this PR: HTTP 500, plus a *fs.PathError reported to Sentry.

It had no HTTPError() method, so it surfaced as a 500.
A file row whose blob is gone from storage (Sentry API-OSS-50) made
LoadFileByID return the raw storage path error, which the error handler
turned into a 500 and reported to Sentry. Return ErrFileDoesNotExist
instead and update the callers that matched on the path error.
@github-actions github-actions Bot added area/attachments File attachments on tasks: upload, preview, download area/avatars User avatar providers (Gravatar, LDAP, upload) and rendering labels Sep 4, 2026
@kolaente
kolaente enabled auto-merge (rebase) September 4, 2026 20:58
@github-actions github-actions Bot added the auto-merge PR has GitHub auto-merge enabled label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Preview Deployment

Preview deployments for this PR are available at:

URL Tag Commit
https://pr-3734.preview.vikunja.dev ghcr.io/go-vikunja/vikunja:pr-3734 latest
https://sha-8df34db298a89193750f3653277b4571eb406044.preview.vikunja.dev ghcr.io/go-vikunja/vikunja:sha-8df34db298a89193750f3653277b4571eb406044 8df34db
https://sha-8550d087e55395afc9f46632f98c2ec7c2677c47.preview.vikunja.dev ghcr.io/go-vikunja/vikunja:sha-8550d087e55395afc9f46632f98c2ec7c2677c47 8550d08

The preview environment will start automatically on first visit. Subsequent pushes to this PR will update the pr-3734 image — the preview picks up the new version on restart. The per-commit URLs point to a specific version and will not change.

Run locally with Docker
docker pull ghcr.io/go-vikunja/vikunja:pr-3734
docker run -p 3456:3456 ghcr.io/go-vikunja/vikunja:pr-3734

Last updated for commit 8df34db

@kolaente
kolaente merged commit 37649d1 into main Sep 4, 2026
44 checks passed
@kolaente
kolaente deleted the fix-missing-avatar-file branch September 4, 2026 21:36
@github-actions github-actions Bot removed the auto-merge PR has GitHub auto-merge enabled label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/attachments File attachments on tasks: upload, preview, download area/avatars User avatar providers (Gravatar, LDAP, upload) and rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants