Skip to content

Fix Catalogue tab 500ing on first load, and declare rustler explicitly for mdex_native - #25

Merged
ddon merged 2 commits into
BeamLabEU:mainfrom
timujinne:upstream-fixes/catalogue-tab-500-and-rustler-declare
Aug 22, 2026
Merged

Fix Catalogue tab 500ing on first load, and declare rustler explicitly for mdex_native#25
ddon merged 2 commits into
BeamLabEU:mainfrom
timujinne:upstream-fixes/catalogue-tab-500-and-rustler-declare

Conversation

@timujinne

@timujinne timujinne commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Two independent fixes on top of upstream/main.

Fix Catalogue tab 500ing on first load for every company

column_picker_available? and catalogue_column_catalog() were only computed in put_catalogue_columns/2, reached from the show/hide/update column-picker event handlers — never from handle_params. The template references @column_picker_available and @catalogue_column_catalog unconditionally whenever tab == "catalogue", so the very first render (the only way to reach those event handlers in the first place) raised KeyError before a user could ever trigger them.

Confirmed live: GET /admin/crm/companies/:uuid?tab=catalogue 500s on every company. Not something PR #75's soft-dependency fix touches; predates it (last touched in 97a086e). Covered by a point test, 5/5 passing.

Declare rustler explicitly so mdex_native force-builds

MDEX_NATIVE_BUILD=1 forces mdex_native to build its NIF from source when no precompiled build exists for the running OTP (28 in our case), which requires rustler itself, not just rustler_precompiled. mdex arrives here transitively through phoenix_kit; a clean checkout fails to compile without this. Same declaration phoenix_kit's own mix.exs already carries.


One fix, six repositories. Every module that pulls mdex transitively through phoenix_kit needs the same one-line declaration, and each repository needs its own PR. Already merged: BeamLabEU/phoenix_kit_catalogue#77, BeamLabEU/phoenix_kit_billing#27. Still open: BeamLabEU/phoenix_kit_warehouse#20, BeamLabEU/phoenix_kit_entities#35, BeamLabEU/phoenix_kit_document_creator#42.

Scope. This makes this repository build from a clean checkout under MDEX_NATIVE_BUILD=1. It does not remove the need for a host application to declare rustler itself: optional dependencies of dependencies are never resolved, so whichever project is the root has to declare it.

MDEX_NATIVE_BUILD=1 in this environment forces mdex_native to build
its NIF from source (OTP 28 ships no precompiled build), which
requires rustler itself, not just rustler_precompiled. mdex arrives
here transitively through phoenix_kit; a clean checkout failed to
compile without this. Same declaration phoenix_kit's own mix.exs
already carries.
column_picker_available? and catalogue_column_catalog() were only
computed in put_catalogue_columns/2, reached from the show/hide/update
column-picker event handlers — never from handle_params. The template
references @column_picker_available and @catalogue_column_catalog
unconditionally whenever tab == "catalogue", so the very first render
(the only way to reach those event handlers in the first place) raised
KeyError before a user could ever trigger them.

Found live: GET /admin/crm/companies/:uuid?tab=catalogue 500s on every
company, confirmed via a real request through AndiWeb.Router against
the live node — not something PR #75's soft-dependency fix touches,
predates it (last touched in 97a086e).
@timujinne

Copy link
Copy Markdown
Contributor Author

Ran the full suite on this branch tip: mix deps.get, mix compile under MIX_ENV=test, then mix test with the :integration half enabled against a real Postgres instance, with MDEX_NATIVE_BUILD=1 set under OTP 28 — the exact scenario the rustler declaration in this PR targets. The declaration compiles and builds the native NIF cleanly in that environment.

618 tests, 0 failures (9 individually skipped, unrelated to this PR).

The Catalogue-tab fix is additionally covered by its own point test mentioned in the description (5/5 passing, included in the above).

@ddon
ddon merged commit f1199e8 into BeamLabEU:main Aug 22, 2026
ddon added a commit that referenced this pull request Aug 22, 2026
Lock the six nav_tabs strips and the Catalogue-tab KeyError with tests,
normalize supplier uuids at process_supplier_row/4 so a raw Postgrex uuid
cannot re-enter company metadata, and always release the catalogue-probe
sandbox owner.
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