Repository navigation
fix(storage): skip transforms for conditional image responses - #5205
Merged
Merged
Conversation
Review issue: 001 — .nhost-code/review/PR_5183_COMMENT_001.md — ADDRESSED, ACCEPT Work unit: PR_5183/RUN-9377675573041723356/WU-001 Resolution: - Skip GET image transformations for 304/412 while retaining downloads, authentication errors, status normalization, and source-body cleanup. - Skip HEAD downloads and transforms when no content length is needed. Why: - Metadata supplies every validator input; bodyless conditional responses do not need decoded images or transformed buffers. Accepted trade-off: - As approved, 304/412 can mask decoding or transformation errors. Explicit invalid options still return 400. GET downloads are deliberately retained. Checks: - `GIN_MODE=release go test -race ./services/storage/controller -count=1` — exit 0: passed; reviewed state unchanged. - `golines --dry-run --base-formatter=gofumpt .` — exit 0: passed; reviewed state unchanged. - `golangci-lint run ./...` — exit 0: 0 issues. - `git diff --check` — exit 0: passed; reviewed state unchanged. - `git diff --cached --check` — exit 0: passed; reviewed state unchanged.
Review issue: 001 — .nhost-code/review/PR_5205_COMMENT_001.md — ADDRESSED, ACCEPT Work unit: PR_5205/RUN-2949609135643056153/WU-001 Resolution: - HEAD 200 headers now describe the transformed representation: a JPEG requested as PNG returns `image/png` and `nhost.jpg.png`, alongside its transformed length. Tests check both headers through the registered HTTP handlers. Why: - Reusing GET's existing representation-name/MIME helper prevents the format mapping from drifting between GET and HEAD. It fixes HEAD metadata for supported preflight requests without changing how files are transformed or downloaded. Decisions: - The resolved filename and MIME type are passed as two private response-builder arguments, rather than overwriting the source metadata or adding a new struct. The existing conditional-response branches are kept as they are, and the helper consolidation reserved for the next work unit is not attempted. Validation limit (operator-approved): - Storage integration startup exited 2: Docker cannot pull minio/minio:RELEASE.2025-02-28T09-55-16Z (insufficient_scope). The operator waived this unavailable gate for both fixes; the integration check was not run. Checks: - `nix develop .#storage --command bash -c 'GIN_MODE=release go test -race ./services/storage/controller -count=1'` — exit 0: passed; staged state unchanged. - `nix develop .#storage --command golines --dry-run --base-formatter=gofumpt .` — exit 0: passed; staged state unchanged. - `nix develop .#storage --command golangci-lint run ./...` — exit 0: 0 issues; staged state unchanged. - `git diff --check 9397e80 --` — exit 0: passed. - `git diff --cached --check` — exit 0: passed.
Review issue: 002 — .nhost-code/review/PR_5205_COMMENT_002.md — ADDRESSED, ACCEPT Work unit: PR_5205/RUN-2949609135643056153/WU-002 Resolution: - Conditional-date and revalidation tests use one metadata fixture, mock/controller/router setup, and regular/presigned/HEAD request builder. Callers supply their original download bodies and errors; absent downloads still leave storage calls forbidden by gomock. Existing test cases and assertions are preserved, including the committed transformed HEAD-header regression coverage. Why: - One shared superset removes fixture, routing, signing-query, and mock-wiring drift without introducing another abstraction or changing production behavior. Decisions: - Keep the two test files separate and place shared helpers in `get_file_conditionals_test.go`. Extend the existing neutral handler name rather than retain a wrapper. Keep `PresignedURLsEnabled: true` from the conditional suite as the shared bucket fixture, eliminating the prior inconsistency; only presigned-URL generation reads that flag, so the revalidation suites' behavior is unchanged. Pass timestamps into the shared metadata builder so the precision regression remains explicit. Review-plan variance: - Code: None. Validation: the MinIO-backed storage integration gate was omitted under the operator-approved exception; full-repository format/lint and the complete controller race suite passed. Checks (staged candidate; reviewed state unchanged): - `nix develop .#storage --command bash -c 'GIN_MODE=release go test -race ./services/storage/controller -count=1'` — exit 0: passed. - `nix develop .#storage --command golines --dry-run --base-formatter=gofumpt .` — exit 0: passed. - `nix develop .#storage --command golangci-lint run ./...` — exit 0: 0 issues. - `git diff --check 373cab0 --` — exit 0: passed. - `git diff --cached --check` — exit 0: passed. - Storage integration check — not run under operator waiver: pinned MinIO image pull denied (insufficient_scope: authorization failed).
albertomolinafelipe
approved these changes
Oct 20, 2026
sepples
approved these changes
Oct 20, 2026
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.
Goal
Avoid decoding and transforming images when storage can answer a conditional request with a bodyless 304 or 412 response using metadata validators. Preserve GET downloads and their authorization errors, status normalization, source-body cleanup, and explicit transformation-option validation. For HEAD, avoid downloading or transforming an image when no content length will be returned. Conditional responses intentionally take precedence over image-decoding or transformation failures.
Type: Bug fix
Changes
Key files
services/storage/controller/get_file.go(+16/-13) — Conditional GET evaluation and transformation ordering.services/storage/controller/get_file_metadata_headers.go(+3/-1) — HEAD download/transformation gating.services/storage/controller/get_file_revalidation_test.go(+388/-0) — Endpoint-level regression tests and body-lifecycle observers.