Atom type `cast_stored/2` doesnt use `unsafe_to_atom?` constraint

The cast_input/2 function (https://github.com/ash-project/ash/blob/75a5d8617a5814b3113b9cb3c646dfc687b768dc/lib/ash/type/atom.ex#L86) for the Ash.Types.Atom allows for unsafe parsing of the input value. The cast_stored/2 function does not have this functionality: https://github.com/ash-project/ash/blob/75a5d8617a5814b3113b9cb3c646dfc687b768dc/lib/ash/type/atom.ex#L106 This can be problematic when reading stored atoms from a database that are not in the system yet. This happens when restarting the system for example I was wondering if this was intended behaviour. If not, I can create a PR to fix this. (Its hard to create a reproduction for this because any tests will pass because the atoms will be created when setting up the test)
Solution:
https://github.com/ash-project/ash/pull/2292 One CI check fails but that seems to be a transient issue...
GitHub
Fix bug when casting a non-existing atom from datalayer when `unsaf...
The unsafe_to_atom? constraint was not used by the Ash.Type.Atom.cast_stored/2 function so when casting a stored string to an atom it would throw errors. I've added a test that demonstrates...
Jump to solution
3 Replies
ZachDaniel
ZachDaniel2mo ago
Yeah that sounds like a missing piece to me 🙂 PR welcome 🙇‍♂️
Rutgerdj
RutgerdjOP2mo ago
Alright, PR incoming :D
Solution
Rutgerdj
Rutgerdj2mo ago
https://github.com/ash-project/ash/pull/2292 One CI check fails but that seems to be a transient issue
GitHub
Fix bug when casting a non-existing atom from datalayer when `unsaf...
The unsafe_to_atom? constraint was not used by the Ash.Type.Atom.cast_stored/2 function so when casting a stored string to an atom it would throw errors. I've added a test that demonstrates...

Did you find this page helpful?