Skip to content

User datasets: don't re-upload existing VAF as a blank file on edit - #1957

Open
bobular wants to merge 2 commits into
mainfrom
user-datasets-vaf-placeholder
Open

bobular wants to merge 2 commits into
mainfrom
user-datasets-vaf-placeholder

Conversation

@bobular

@bobular bobular commented Nov 17, 2026

Copy link
Copy Markdown
Member

Fixes #1956

Problem

Editing a dataset's title or summary when it already has a Variable Annotation File (VAF) failed with a blank-VAF error. The cause was in the update form:

  • UpdateFormController seeds dataPropertiesFileSelections with empty placeholders (newUploadContent('', fileName, 'text/plain')) for files already stored on the server, so the form can show their names.
  • newDatasetUploads flattened every selection into the upload list, placeholders included.
  • submitUpdate then saw a non-empty dataPropertiesFiles. The delete step skipped the existing file (its name was still listed), and submitPut PUT the placeholder's empty File as the new VAF.

A related symptom: hasUploads was always true when a VAF existed, so the form always counted as changed and the "nothing to do" state could never occur.

Fix

  • Placeholders are now marked explicitly (isPlaceholder, created by newExistingFilePlaceholder).
  • New newUpdateUploads(state) wraps newDatasetUploads, drops placeholders from dataPropertiesFiles, and leaves it undefined when nothing real remains. submitUpdate already skips the delete/PUT steps in that case.
  • UpdateFormController and UpdateForm use newUpdateUploads. newDatasetUploads is unchanged, so the upload form is unaffected.

There is no UI path to delete a VAF, so a placeholder only ever means "keep the existing file". Replacing it with a real selection works as before (the new file is uploaded; the old one is deleted if its name differs).

Reviewing

This is two commits so the logic is easy to read:

  1. Format update-form and upload-content files with prettier is formatting only (the repo's pre-commit prettier hook reformats whole staged files, and these files weren't prettier-clean on main). No functional change.
  2. Don't re-upload existing dataset properties files on edit is the actual fix (65 insertions, 8 deletions).

Testing

  • Tested manually in the UI: a title-only edit on a dataset with a VAF no longer errors or touches the VAF, and re-uploading the same file, or a same-name edited file, through the file upload UI enables Submit and the file is uploaded (not ignored).
  • No automated tests were added.
  • tsc shows only the 3 existing errors in src/index.tsx, none in the touched files.

Note on #1953

#1953 also edits UpdateFormController.tsx, on nearby but different lines. The changes are logically independent, but whichever merges second may need a small textual conflict resolved.

🤖 Generated with Claude Code

bobular and others added 2 commits November 17, 2026 12:06
Formatting only, no functional change. Done separately so the follow-up
fix commit shows just the logic.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The update form seeds its file selections with empty placeholders for
files already on the server (e.g. the Variable Annotation File).
newDatasetUploads treated them as real uploads, so a title-only edit PUT
a blank file over the stored VAF, and the form always looked changed.

Mark placeholders explicitly and filter them out via newUpdateUploads, so
submitUpdate skips the delete/PUT steps when nothing real was selected.
Replacing the file with a real selection still works as before.

Fixes #1956

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@bobular bobular left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bobular

bobular commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

When merging before or after #1953 there will be a small conflict:

<<<<<<< HEAD (the VAF branch)
  newExistingFilePlaceholder(it.fileName)
=======
  newUploadContent('', it.fileName, 'text/plain')
>>>>>>> user-datasets-modal-state

This is a conflict due to prettier formatting only.

The correct resolution is to keep the newExistingFilePlaceholder(it.fileName)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: revising title and summary without re-uploading VAF file results in blank VAF file error.

1 participant