fix: let the import upload form submit without job params #46

Merged
jfro merged 1 commit from jtk/fix-import-upload into main 2026-10-18 18:21:37 +00:00
Owner

Fixes #45.

Found in the v0.6.0 prod-image smoke run on df180a7: uploading a file on Admin → Import/Export → Import Data always returned 400 (Phoenix.ActionClauseError), because create_import/2 required a "job" param that the form never sends. The controller tests posted "job" => %{} by hand, so they didn't catch it. The bug was already in v0.5.1.

  • create_import/2 now takes any params and defaults job_params to %{}.
  • New tests: upload with only a file (how the browser sends it) goes to the preview; submit with no file shows "Please select a file to import" instead of crashing. The first test fails on main with ActionClauseError.

mix precommit: 533 passed, 4 skipped. I'll rebuild the prod image with this and re-run the import round trip.

Fixes #45. Found in the v0.6.0 prod-image smoke run on df180a7: uploading a file on Admin → Import/Export → Import Data always returned **400** (`Phoenix.ActionClauseError`), because `create_import/2` required a `"job"` param that the form never sends. The controller tests posted `"job" => %{}` by hand, so they didn't catch it. The bug was already in v0.5.1. - `create_import/2` now takes any params and defaults `job_params` to `%{}`. - New tests: upload with only a file (how the browser sends it) goes to the preview; submit with no file shows "Please select a file to import" instead of crashing. The first test fails on main with `ActionClauseError`. `mix precommit`: 533 passed, 4 skipped. I'll rebuild the prod image with this and re-run the import round trip.
fix: let the import upload form submit without job params
All checks were successful
CI / test (pull_request) Successful in 46s
2a1c637704
The upload form only has a file input, so browsers send no "job"
params and create_import/2 raised ActionClauseError (400). Default
the job params to an empty map and test the form as a browser sends it.

Fixes #45
jfro left a comment

Review by Nye: APPROVED at head 2a1c637.

Removing the %{"job" => _} match is right; job_params is only used to rebuild the changeset when re-rendering the form with an error, never for the insert (create_import_job takes file_info), so defaulting to %{} adds no new input path. Both new tests cover the real browser shape and the no-file case. CI green, mergeable, based directly on df180a7.

Non-blocking nit (pre-existing, admin-only, defer): a non-upload string "file" param crashes handle_file_upload with a 500 instead of a form error; could pattern-match %Plug.Upload{} later.

(Posted by Upper Wolfjaw on Nye's behalf.)

**Review by Nye: APPROVED** at head 2a1c637. Removing the `%{"job" => _}` match is right; `job_params` is only used to rebuild the changeset when re-rendering the form with an error, never for the insert (`create_import_job` takes `file_info`), so defaulting to `%{}` adds no new input path. Both new tests cover the real browser shape and the no-file case. CI green, mergeable, based directly on df180a7. Non-blocking nit (pre-existing, admin-only, defer): a non-upload string "file" param crashes `handle_file_upload` with a 500 instead of a form error; could pattern-match `%Plug.Upload{}` later. _(Posted by Upper Wolfjaw on Nye's behalf.)_
jfro merged commit 3fa6a13d6c into main 2026-10-18 18:21:37 +00:00
jfro deleted branch jtk/fix-import-upload 2026-10-18 18:21:38 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/fuzzy_catalog!46
No description provided.