ekosz

ekosz

Reactor not recognizing inputs transform?

Hi there, I have the following Reactor code:

defmodule CreateNewAccount do
  use Reactor, extensions: [Ash.Reactor]
  alias Accounts.Account

  ash do
    default_domain Accounts
  end

  input(:email)
  input(:email_is_verified?)

  create :account, Account do
    inputs %{
      email: input(:email),
      email_is_verified?: input(:email_is_verified?)
    } do
      transform(fn input ->
        input
        |> Map.drop([:email_is_verified?])
        |> Map.put(
          :email_verified_at,
          if input[:email_is_verified] do
            nil
          else
            DateTime.now()
          end
        )
      end)
    end
  end
end

But I’m getting the following error

Compiling 2 files (.ex)

== Compilation error in file lib/create_new_account.ex ==
** (Spark.Error.DslError) [CreateNewAccount]
reactor -> create -> account:
  The create step `:account refers to an input named `email_is_verified?` which doesn't exist.

Did you mean `updated_at`, `created_at`, `id`, `email` or `email_verified_at`?

Looks like the DSL isn’t recognizing that I’m transforming the input. Is this a bug or am I just doing something incorrect?

Thank you!

First Post!

zachdaniel

zachdaniel

Creator of Ash

Took me a while to notice this :slight_smile:

The error message is confusing here due to the overloaded term “input”. What reactor is doing here is telling you that the create action on Account that it is calling does not accept an input called email_is_verified?.

So you’d need either an argument on that action or to accept that field as input using accept to resolve this error.

Most Liked

jimsynz

jimsynz

Ash Core Team

Yeah that makes sense. We can’t validate the keys statically if the input is being transformed. @ekosz do you mind opening an issue on ash (it’s an Ash.Reactor bug) and I’ll tackle it once I am back from my holiday. In the mean time you can move that behaviour into a change on the underlying action or process it as a seperate step so that the input map has the correct keys.

Last Post!

ekosz

ekosz

Sounds good! Created the issue here: Issue · GitHub

Let me know if you would like me to add any additional context

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement