diff --git a/HANDOVER_ISSUE_1401.md b/HANDOVER_ISSUE_1401.md new file mode 100644 index 0000000000..de1db1c9c6 --- /dev/null +++ b/HANDOVER_ISSUE_1401.md @@ -0,0 +1,629 @@ +# HANDOVER DOCUMENT: Issue #1401 + +## Issue Summary + +**Title:** [Bug] Partial editing of sample metadata possible although invalid information present +**Issue ID:** #1401 +**Severity:** High +**Status:** Open (In Progress) +**Component:** Sample Management - Edit Sample Batch Dialog + +### One-Sentence Summary +Users can proceed with sample batch registration/editing despite validation errors being displayed, allowing invalid metadata to be processed. + +--- + +## Issue Details + +### Full Description +When editing a sample batch using the "Edit Sample Batch" workflow, users are able to click the confirmation button even after the validation process has detected errors. The dialog displays validation error messages (e.g., "missing species", "missing specimen"), but these errors do not prevent the user from confirming and proceeding with the registration operation. + +### Steps to Reproduce + +1. Navigate to a project with experiments and sample batches +2. On the Register/Edit Sample Batch page, click on **Edit** for an existing batch +3. Click **Download the metadata template** to get the XLSX file +4. Open the downloaded XLSX file and **remove required fields** (e.g., delete species, specimen, or analyte by pressing DEL) +5. Save and **upload the modified XLSX file** back to the dialog +6. Observe the validation results displayed in the upload section +7. **The validation display shows errors** (e.g., "Invalid sample metadata", "Missing species for 1 sample") +8. Click the **"Edit Batch" confirmation button** despite the errors being visible +9. **Expected:** Button should do nothing or be disabled + **Actual:** Dialog closes, registration is triggered, and a success toast is shown + +### Environment Details + +- **Affected Browsers:** Microsoft Edge, Safari, Firefox, Chrome (all major browsers) +- **Affected Workflows:** + - Edit Sample Batch (primary manifestation) + - Likely also Register Sample Batch (same code structure) +- **Application Version:** 1.11.0 + +### Error Messages / Logs + +**In Dialog Display:** +- "Invalid sample metadata" +- "Missing species for X samples" +- "Missing specimen for X samples" +- "Missing analyte for X samples" +- Other validation-related messages + +**User Observation:** +- Success toast appears: "Your data has been approved" or similar +- Registration completes despite validation failures + +### Provided Files + +- Valid example: `2026-03-20_Q2RGU6_sample-metadata-update-template.xlsx` +- Invalid example: `2026-03-20_Q2RGU6_sample-metadata-update-template_invalid.xlsx` + +--- + +## Behavior Analysis + +### Expected Behavior + +1. **Given:** A file has been uploaded and validation has completed with errors + **When:** User clicks the confirm button + **Then:** The button click should have no effect (remain in edit state, show error indicator on button) + +2. **Given:** A file has been uploaded and validation has completed successfully + **When:** User clicks the confirm button + **Then:** Dialog should proceed with registration and display progress + +3. **Given:** Validation is displaying errors + **When:** User attempts to proceed + **Then:** The confirm button should be visually disabled or the action should be blocked + +### Observed Behavior + +1. **Actual:** Even when validation errors are displayed (showing "Invalid sample metadata" with specific error counts), the confirm button remains active and clickable + +2. **Actual:** Clicking the confirm button while validation errors are displayed: + - Closes the dialog immediately + - Triggers the confirmation event to the parent component + - Proceeds with sample registration/update despite invalid data + - Shows success notification + +3. **Actual:** The `validatedSampleMetadata` list becomes populated with data even when validation has failed, because: + - When validation fails, the UI display is updated with error information + - The `validatedSampleMetadata` list is NOT cleared when validation shows failures + - OR the state tracking doesn't prevent the confirm action from proceeding + +### Impact + +- **Severity:** High +- **User Impact:** Users can register invalid sample metadata that violates data quality requirements, compromising data integrity in the system +- **System Impact:** Invalid or incomplete sample metadata may propagate through the system, affecting: + - Project data completeness + - Subsequent operations dependent on sample metadata + - FAIR data export compliance + - Reporting and analysis accuracy + +--- + +## Root Cause Analysis + +### Probable Root Cause + +The issue appears to be in the `onConfirmClicked()` method of both `EditSampleBatchDialog` and `RegisterSampleBatchDialog`. These dialogs perform validation checks on the batch name field, but **they do NOT validate that valid sample metadata has been uploaded and passed validation**. + +**The gap:** When validation fails for the uploaded sample file: +1. The error display is updated in the UI (lines 216-221 in EditSampleBatchDialog) +2. `setValidatedSampleMetadata(List.of())` is called to clear the validated list +3. **However**, in the `onConfirmClicked()` method, there is no check to ensure `validatedSampleMetadata` is non-empty or that validation actually succeeded + +**In EditSampleBatchDialog.onConfirmClicked() (lines 339-354):** +```java +@Override +protected void onConfirmClicked(ClickEvent