Forgotten `change` in update action leads to hours of troubleshooting and sadness
I forgot a
change
in front of a set_attribute
in an update
action and nothing really reacted to that except that the attribute wasn't set. Is there a flag I can set somewhere to have Spark or Ash or something crash loudly at me when I use keywords in wrong places?
Sad code:
Happy code:
10 Replies
We've had this issue multiple times, and honestly its just a weirdly hard problem to solve 😢
Oh no. 🙁 Well at least I know I'm not alone in this.
it is silly that it can happen, I just haven't found a good way to prevent it 😢
Seems like something that a Credo check could spot and warn about
Its possible, but not super easy
arbitrary code can go in actions
i.e
We could try and spot builtin changes without
change
What if that macro is evaluated/normalized/demacrofied and then the check is run? Or is it still possible to have any Elixir you want in the action?
I don't think it really works that way
I don't know of like an ability to do a post-expension pass like that
There could be an 80/20 solution maybe? Like setting up a whitelist of "must be there"s. For example, I don't think we can have a
resources do
block without a resource
macro inside, right?Potentially yes
I see no reason for folks not to build credo checks like that
or to have an
ash_credo
package for exampleI was hoping it was possible. Oh well.