Skip to content

Catalogue 0.7.0: European prices import correctly and PDFs survive a bad page

Catalogue 0.7.0 fixes prices in European format that were imported about a thousand times too small, makes CSV import pick the right separator, and keeps a PDF’s text when only one page can’t be read.

Import

A price written as 1.234,56, with a dot for thousands and a comma for decimals, was read as 1.23456. The importer now takes whichever of the dot or comma comes last as the decimal separator, so both 1,234.56 and 1.234,56 read correctly, also with a currency sign in front.

The separator of a CSV file was guessed by counting commas, semicolons and tabs on the first line, so a quoted header with a comma in it turned every row into one column. The importer now tries each separator on a sample of lines and picks the one that gives a steady number of columns.

Uploads larger than 25 MB or with more than 50,000 rows are refused with a clear message instead of being loaded into memory. The duplicate check before an import only looks at items whose name appears in the file.

PDF text extraction

One unreadable page used to mark the whole PDF as failed and throw away every page that had been read. Extraction now skips the bad pages, keeps the rest and fails only when no page can be read. An upload could also be left waiting with no extraction job; it is now queued again whenever it is seen waiting.

Upgrading

No migration. The forms now use the AI translation wiring from PhoenixKit core, so use PhoenixKit 1.7.132 or later; the module’s own requirement still allows 1.7.125.

Full release notes: Catalogue 0.7.0

0.7.0 · 7 June 2026

Fixed

  • European number formats in price import — Import.Mapper.normalize_price/1 mis-parsed the European "1.234,56" convention (dot thousands, comma decimal): it stripped the comma and read the value as 1.23456 — silently off by ~1000×. It now decides the decimal separator by whichever of ./, appears last, so both "1,234.56" (US/UK) and "1.234,56" (EU) parse correctly, including multi-group values and currency-prefixed strings.
  • CSV delimiter mis-detection on quoted headers — Import.Parser chose the delimiter by counting raw ,/;/\t characters on the first line, so a quoted header cell containing a comma (e.g. "Name, full";…) picked the comma parser and collapsed every row to a single column, silently importing garbage. Detection now parses a sampled set of lines with each candidate parser and scores by column count + consistency, which is immune to delimiters inside quotes.
  • PDF extraction enqueue could be silently dropped — the post-insert enqueue was gated on a 1-second wall-clock “was I the inserter?” heuristic; under DB/GC latency the inserting caller could arrive later and skip the enqueue, leaving a pending extraction with no job (only the manual Retry stuck path would heal it). It now (re-)enqueues on any pending observation — enqueue_extraction/1 is already idempotent against live jobs, so this is safe and self-healing.
  • One bad PDF page no longer fails the whole document — Workers.PdfExtractor halted extraction on the first page error and marked the entire PDF failed, discarding every successfully-extracted page and burning all retries on a single corrupt page. It now continues past per-page failures, keeps the usable partial result (logging the unreadable pages), and only fails — for retry — when every page fails.

Changed

  • Import upload guards — Import.Parser.parse/3 and list_sheets/1 now reject oversized inputs up front (:file_too_large above 25 MB, :too_many_rows above 50 000) instead of materializing a pathological upload into memory. Both atoms have user-facing Errors.message/1 copy.
  • Bounded duplicate-detection query — Import.Mapper.detect_existing_duplicates/3 narrows its existence query to items whose name appears in the import (a match requires name equality) instead of loading every non-deleted item in the catalogue into memory.
  • AI-translate LiveView wiring via the AITranslate.Embed macro (#33) — the catalogue/category/item form LiveViews replaced their hand-wired AI-translate handlers (six ai_* handle_event clauses + the {:ai_translation} handle_info) with use PhoenixKitWeb.Components.AITranslate.Embed from core, which attaches the modal/dispatch/PubSub handlers as lifecycle hooks. Requires the macro shipped in core (BeamLabEU/phoenix_kit#585).
  • nimble_csv declared as a direct dependency — the CSV import parser uses it directly (NimbleCSV.define/2); it was only pulled transitively via phoenix_kit. Loosely constrained (~> 1.2).

Docs

  • Fixed a stale “SKU is unique” note in the create_item/update_item docs — core V123 dropped that index; item SKUs are non-unique by design.

Notes

  • Requires a phoenix_kit release containing PhoenixKitWeb.Components.AITranslate.Embed (BeamLabEU/phoenix_kit#585) — the macro the form LiveViews now use. Developed and locked against core 1.7.132; the mix.exs constraint stays loose (~> 1.7 and >= 1.7.125), so pin a phoenix_kit >= 1.7.132 in the parent app.
  • Verification: mix precommit is clean (compile --warnings-as-errors + format --check-formatted + credo --strict + deps.unlock --check-unused + dialyzer). The new pure-function behavior (price normalization, delimiter detection, size/row caps) is covered by added unit tests. The full ExUnit suite is DB-gated — run mix test against a host with PostgreSQL.
  • Deferred follow-up: several form LiveViews still issue DB queries directly in mount/3 (which runs twice). Documented in dev_docs/followup_2026_06_07_mount_connected_guard.md; deferred because validating the disconnected-render change needs the DB-backed LiveView test suite.

Catalogue 0.7.0. Install or update: {:phoenix_kit_catalogue, "~> 0.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.