Summary
The CSV import path can crash before it reaches error handling when a file contains duplicate header names.
Evidence
ios/NetWorthIOS/Services/CSVService.swift:50-55 normalizes header names and immediately builds columnIndex with Dictionary(uniqueKeysWithValues:).
Dictionary(uniqueKeysWithValues:) traps on duplicate keys instead of returning a recoverable error.
- This means malformed files with repeated columns such as
values or updatedAt bypass the intended ImportError.invalidHeader path and can terminate the import flow.
- Source basis: dirty workspace change in
ios/NetWorthIOS/Services/CSVService.swift.
Why This Matters
A malformed backup should fail gracefully. Crashing the import flow turns a user-data recovery action into an app-stability issue and makes it harder to explain what was wrong with the file.
Suggested Direction
Validate the normalized header row for duplicates before constructing the dictionary, and surface a controlled import error when duplicates are present.
Acceptance Criteria
- Duplicate header names are detected without crashing.
- The importer returns a controlled error for duplicate-column CSVs.
- The UI shows a normal import failure notice instead of terminating the flow.
- Add a regression test covering duplicate headers after BOM/whitespace normalization.
Deduping Notes
Checked open issues #1 and #2; neither covers CSV parsing or import crash handling.
Summary
The CSV import path can crash before it reaches error handling when a file contains duplicate header names.
Evidence
ios/NetWorthIOS/Services/CSVService.swift:50-55normalizes header names and immediately buildscolumnIndexwithDictionary(uniqueKeysWithValues:).Dictionary(uniqueKeysWithValues:)traps on duplicate keys instead of returning a recoverable error.valuesorupdatedAtbypass the intendedImportError.invalidHeaderpath and can terminate the import flow.ios/NetWorthIOS/Services/CSVService.swift.Why This Matters
A malformed backup should fail gracefully. Crashing the import flow turns a user-data recovery action into an app-stability issue and makes it harder to explain what was wrong with the file.
Suggested Direction
Validate the normalized header row for duplicates before constructing the dictionary, and surface a controlled import error when duplicates are present.
Acceptance Criteria
Deduping Notes
Checked open issues #1 and #2; neither covers CSV parsing or import crash handling.