Skip to content

fix: try converting value to existing atom before dumping.#50

Merged
Torkan merged 2 commits intomainfrom
fix-atom-dump-value
Jul 12, 2025
Merged

fix: try converting value to existing atom before dumping.#50
Torkan merged 2 commits intomainfrom
fix-atom-dump-value

Conversation

@Torkan
Copy link
Copy Markdown
Collaborator

@Torkan Torkan commented Jul 12, 2025

Ensure atom attributes are converted to existing atoms before calling Ash.Type.dump_to_embedded.

When the passed value is a string, this caused an error due to the one_of constraints check failing.

def dump_value(value, attribute) do
value =
if attribute.type == Ash.Type.Atom and is_binary(value),
do: String.to_existing_atom(value),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this implies a missing step, like of first casting input?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, agreed!

Updated the code to use cast_input for all values before dumping now.

@Torkan Torkan merged commit 53f94c3 into main Jul 12, 2025
20 of 21 checks passed
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