Repository navigation
Hide project screenshots whose file is gone from storage - #10
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The leaderboard, buddy, buddy invite, project and ship pages checked only that the screenshot's blob row exists. When the file is gone from local-disk storage, the row stays and the page shows a broken image. Project#stored_screenshot also checks the file, and logs screenshot_file_missing to PostHog Logs when it is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 5acce8a2-b26d-48b2-ac7a-fbb3ccaebe88
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/leaderboardand/buddysee broken image icons where project screenshots should be. The image requests return 404.blob.persisted?. That checks the database row, not the file. Production stores files on local disk, and the blob rows live in Postgres. When a file goes from disk, the row stays and the page still renders the image.Origin
476ecf9Changes
Project#stored_screenshotreturns the screenshot only when the storage service has its file. Else it returnsnil, and the page shows no image (or the "Add a screenshot" placeholder on the project page).Project#ship!copies the old screenshot to a ship only when its file exists. Else the ship form asks for a new screenshot.screenshot_file_missingwarning to PostHog Logs through the existingPosthogLog. This gives a count of missing files, which the report could not get before./leaderboard,/buddy, buddy inviteWarning
This PR does not fix the root cause. If the host does not keep
/rails/storageacross redeploys, uploaded files are still lost.config/deploy.ymlmounts thewrong_tool_storagevolume, but somebody with host access must confirm that the host uses it, or move Active Storage to a durable service such as S3.Note
The check costs one
File.exist?call per screenshot on the Disk service. The leaderboard rows are also built for the sidebar on the project page. If Active Storage moves to S3, each check becomes a HEAD request, so revisit this check then.Tests
stored_screenshotisnilafter the file is deleted from storage.bin/rails test(137 runs, 0 failures) andbin/rubocop(no offenses), on Ruby 3.2.3 because the sandbox has no Ruby 3.4.3.Agent context
onerrorhandler. It still sends the failing request, and it needs a Stimulus controller on each image.imgtag for a missing file.Created with PostHog Desktop from this inbox report.
🤖 Generated with Claude Code