You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank your for maintaining cloak_ecto!
I was wondering, in terms of usability, wouldn't it make sense for the library to throw an error when no cipher is configured?
As far as I can see, the library is unusable without a suitable configuration.
My reasoning for this is, I just spent an hour attempting to figure out the following error:
**(Ecto.ChangeError) value `"test"` for `MyModel.encrypted_api_token` in `update` doesnotmatchtypeMyApp.Encrypted.Binary(ecto3.5.3) lib/ecto/repo/schema.ex:889: Ecto.Repo.Schema.dump_field!/6(ecto3.5.3) lib/ecto/repo/schema.ex:898: anonymousfn/6inEcto.Repo.Schema.dump_fields!/5(stdlib3.12) maps.erl:232: :maps.fold_1/3(ecto3.5.3) lib/ecto/repo/schema.ex:896: Ecto.Repo.Schema.dump_fields!/5(ecto3.5.3) lib/ecto/repo/schema.ex:829: Ecto.Repo.Schema.dump_changes!/6(ecto3.5.3) lib/ecto/repo/schema.ex:334: anonymousfn/15inEcto.Repo.Schema.do_update/4(ecto3.5.3) lib/ecto/repo/schema.ex:177: Ecto.Repo.Schema.update!/4(elixir1.11.1) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
However, I searched in all the wrong places. I double checked all my database types, checked if my ecto adapter (myxql) supported the correct data type, updated ecto, etc. etc... After a lot of digging, I ended up adding an inspect to lib/cloak_ecto/type.ex in dump/1's error clause and got this helpful message %Cloak.InvalidConfig{message: "could not encrypt due to missing configuration"}}
As it turns out, I had put the following in my vault module:
Also a thanks from me for cloak_ecto! And ➕ 1 on this. I ran into a similar error and was thrown off until I eventually found this GitHub issue. Thanks for considering!
@cybrox@paulstatezny This is actually an issue for the cloak package, because that's where this error would need to be implemented. It does already return an error when you call encrypt with invalid configuration:
First of all, thank your for maintaining
cloak_ecto
!I was wondering, in terms of usability, wouldn't it make sense for the library to throw an error when no cipher is configured?
As far as I can see, the library is unusable without a suitable configuration.
My reasoning for this is, I just spent an hour attempting to figure out the following error:
However, I searched in all the wrong places. I double checked all my database types, checked if my ecto adapter (myxql) supported the correct data type, updated ecto, etc. etc... After a lot of digging, I ended up adding an
inspect
tolib/cloak_ecto/type.ex
indump/1
's error clause and got this helpful message%Cloak.InvalidConfig{message: "could not encrypt due to missing configuration"}}
As it turns out, I had put the following in my vault module:
After changing
:cyphers
to:ciphers
, as it is spelled in the docs, everything worked fine 🤦So I was wondering, wouldn't it make sense to throw an error when no
cipher
configuration is provided at all?The text was updated successfully, but these errors were encountered: