Ash: Atomic Update Validations - KeyError - key :atomics not found

I get the following error when trying to use the built in string_length validation on an update action:

** (Ash.Error.Unknown)
Bread Crumbs:
Exception raised in: Module.change_secret
Unknown Error
(KeyError) key :atomics not found in: {:not_atomic,
"Failed to validate expression string_length(secret) > 64: “Invalid reference “secret””}

My update action looks like this:

update :change_secret do
  argument :secret, :string, allow_nil?: false

  validate string_length(:secret, min: 8, max: 64)

  change {HashSecret, argument: :secret, field: :hashed_secret}
end

It looks like ash/lib/ash/resource/validation/string_length.ex at main · ash-project/ash · GitHub has the atomic function so I’m not sure what I’m doing wrong. (The create works as expected with the validation and the custom HashSecret change working well.)

Hey there! So there are two issues here.

The first one is a bug in string_length. I will fix that now.

The second is something thats an after effect of the first issue, but to fix it could you please provide the stacktrace of the error you received?

I’ve fixed the first issue in main if you could please give it a try. That will also likely fix the second issue, but I still need that stacktrace to fix that one :smiley:

@zachdaniel

The update made to main fixed the issue, everything appears to be working as expected now. Thanks!

1 Like

I’ve got the stacktrace for the second issue from another user.