fix(bulk-upload): match error chips by filename, not by chunk position
save() was marking the first N files in a chunk as errored (where N = the error count returned by the backend), but the backend errors are keyed by filename. A failure for file[2] would incorrectly mark file[0] as the error. Now builds a Set of error filenames and matches chunk entries by file.name. Test added: save marks only the file whose filename matches the backend error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -109,10 +109,14 @@ async function save() {
|
||||
if (!res.ok) {
|
||||
hadErrors = true;
|
||||
const body = await res.json().catch(() => ({ errors: [] }));
|
||||
const errorCount = (body.errors ?? []).length;
|
||||
for (let j = 0; j < errorCount && j < chunk.length; j++) {
|
||||
const e = files.get(chunk[j].id);
|
||||
if (e) files.set(chunk[j].id, { ...e, status: 'error' });
|
||||
const errorFilenames = new Set<string>(
|
||||
(body.errors ?? []).map((err: { filename: string }) => err.filename)
|
||||
);
|
||||
for (const entry of chunk) {
|
||||
if (errorFilenames.has(entry.file.name)) {
|
||||
const e = files.get(entry.id);
|
||||
if (e) files.set(entry.id, { ...e, status: 'error' });
|
||||
}
|
||||
}
|
||||
}
|
||||
chunkProgress = { done: i + 1, total: chunks.length };
|
||||
|
||||
Reference in New Issue
Block a user