Repository navigation
fix(storage): preserve original filename when replace metadata omits name - #5271
Merged
dbarrosop merged 2 commits intoOct 29, 2026
Merged
Conversation
Review issue: 001 — .nhost-code/review/PR_5271_COMMENT_001.md — ADDRESSED, ACCEPT Work unit: PR_5271/RUN-15465586466490894737/WU-001 Resolution: - Reuse the ReplaceFile table for distinct metadata-name overrides, omitted/empty names, and absent metadata; match persisted names and metadata. - Parameterize multipart input separately and remove the duplicate regression harness while retaining large-file and file-size coverage. Why: - A lost override now fails the storage argument matcher instead of passing because upload and metadata names happen to match. Decisions: - Cover both fallback inputs and nil metadata without new dependencies. - Keep the linter-required parser blank line; parser logic is unchanged. Checks: - `nix develop .#storage -c golines -l --base-formatter=gofumpt .` — exit 0: no files require formatting. - `nix develop .#storage -c golangci-lint run ./...` — exit 0: 0 issues. - `nix develop .#storage -c go test -count=1 ./services/storage/controller/...` — exit 0: controller tests passed. - `git diff --check 8984c78 --` — exit 0: no whitespace errors.
dbarrosop
force-pushed
the
fix/storage-replace-file-filename
branch
from
October 29, 2026 14:23
967a029 to
0f95f89
Compare
dbarrosop
approved these changes
Oct 29, 2026
dbarrosop
enabled auto-merge (squash)
October 29, 2026 14:37
Member
|
Thanks! |
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.
Description
When replacing a file via
PUT /v1/files/{id}with custom metadata, if themetadataJSON object does not explicitly include a"name"field (for example,{"metadata": {"category": "invoices"}}), the unmarshaledreplaceFileMetadata.Namedefaults to"".Previously,
replaceFileParseRequestunconditionally overwroteres.Name = d.Name, erasing the legitimate filename extracted from the multipart file header (file[0].Filename). Consequently, an empty string""was written to PostgreSQLstorage.files.name, corrupting theContent-Dispositiondownload header and breaking dashboard displays.Changes
replaceFileParseRequestinservices/storage/controller/replace_file.goto only overwriteres.Nameifd.Name != "", preserving the multipart filename when metadata omitsname(aligning with the behavior inupload_files.go).TestReplaceFile_PreservesFilenameWhenMetadataOmitsNameinservices/storage/controller/replace_file_test.go.Checklist