fix: atomize metadata map - #77
Open
vittorio-reinaudo wants to merge 2 commits into
Open
Conversation
Member
|
Please add tests |
vittorio-reinaudo
force-pushed
the
fix/atomize-metadata
branch
from
August 14, 2026 19:32
d3d1164 to
e0c9cdb
Compare
2 tasks
ErikFerrari
pushed a commit
to arkemis/arke
that referenced
this pull request
Aug 28, 2026
## Description Metadata reloaded from jsonb comes back with string keys, so the `:transaction` opt-out on arke_project is never read after boot and project creation fails with "cannot create project schema". This makes atom keys the canonical metadata shape, enforced once in `Unit.new/9` where every load path converges. Strings convert via `String.to_existing_atom` (unknown keys stay strings), normalization is shallow, and on a stale string duplicate the atom entry wins. `Unit.update` normalizes data keys the same way, so a string-keyed parameter arg updates the parameter instead of storing a stray key. Breaking for consumers that read `unit.metadata` with string keys after a load: those keys are now atoms when a matching atom exists. Supersedes arkemis/arke-postgres#77, which patched only the boot-time parse in the postgres adapter. ## Related Issue Supersedes arkemis/arke-postgres#77 ## Docs - [ ] I have updated the docs accordingly ## Test - [x] I have added tests that prove my fix is effective or that my feature works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug: transaction flag in metadata never read due to atom/string key mismatch
In arke lib, in_transaction/2 (used by QueryManager) checks arke.metadata for a :transaction key using an atom:
However, metadata is not parsed into atom keys — it's loaded with string keys (e.g. "transaction"). As a result, Map.get/3 always misses and falls back to the default (true), so the transaction: false option in metadata is silently ignored and every call runs inside a transaction regardless of what's configured.
Suggested fix: either parse metadata keys to atoms before this check, or look up the string key directly (e.g. Map.get(arke.metadata || %{}, "transaction", true)), depending on how metadata is handled elsewhere in the codebase for consistency.
Repro
Su un arke_system già seedato (cioè il percorso normale a runtime con progetto avviato):