Skip to content

fix(ui): accept the header_mapping log step, so imports no longer show as Failed - #223

Draft
amar-python wants to merge 1 commit into
mainfrom
claude/fix-header-mapping-log-step
Draft

amar-python wants to merge 1 commit into
mainfrom
claude/fix-header-mapping-log-step

Conversation

@amar-python

Copy link
Copy Markdown
Owner

Every dynamic-mode import through the React app currently shows as Failed even though the server saved it.

What happens on main

The React app sends a header mapping with every dynamic upload. Since #202 (#186), the API then adds a header_mapping entry to the upload's logs. The app's response schema (processingLogSchema) did not list that step, so zod rejected the whole response:

Unexpected response shape from /api/csv/upload: logs.3.step: Invalid option: expected one of "receive"|"hash"|…

The import itself had succeeded: the file appeared under "Migrated files" while the upload report said "Failed". Reproduced with the real API and the Vite dev server in Chromium. With the API alone: upload with headerMapping returns steps receive, hash, parse, header_mapping, …; index 3 is the logs.3 in the error.

Fix

  • Add header_mapping to the schema's step list.
  • Export the schema, and add log-step-contract.test.ts: it reads every _log(logs, "<step>", …) in api/services and api/routers and checks the schema accepts each, so the next new step fails a test and not the upload screen. Both new assertions fail on main (expected ['header_mapping'] to equal []) and pass here.

Tests

  • vitest 168/168, tsc clean
  • The browser end-to-end run that found this (in the tests branch) goes from "Failed" to "Imported" with this change.

Why #186's own tests missed it: they check the API and the database column, and the frontend tests mock the upload response, so nothing ran the real response through the real schema.


Generated by Claude Code

…w as Failed

#186 made the API return a header_mapping step in an upload's logs. The
React app's response schema did not list it, and the React app sends a
header mapping with every dynamic upload. zod rejected the whole response
("Unexpected response shape ... logs.3.step"), so an import that had
succeeded on the server was shown as Failed.

Add the step, export the schema, and test that it accepts every step the
API's loaders can pass to _log(), so the next new step fails a test, not
the upload screen.

Found by the browser end-to-end tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011T6Wqi8yaiaYWUVH8C4QAY
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.

2 participants