Unexpected error Enumerable not implemented for nil of type Atom
#286
Labels
bug
Something isn't working
Enumerable not implemented for nil of type Atom
#286
Versions Used
Kaffy: master
Phoenix: 1.7
Elixir: 1.15.4
What's actually happening?
If you don't use the auto-discovery feature, that is, if you pass a function or a list to the
resources
config and forget to add one of the relationships to theresources
list as well, you get an unexpected error while going to the edit page of a resource.For instance, if I have a schema called
Foo
with abelongs_to :bar, Bar
relationship and I only addFoo
and notBar
to theresources
configuration it raises an exception:protocol Enumerable not implemented for nil of type Atom
when I edit it.What should happen instead?
So, I understand that Kaffy needs all the relationships configured in the
resources
key to properly build the pages, but this is not immediately clear what it expects when you stumble upon this error... The error happens mostly becauseget_context_for_schema
can returnnil
andget_schema_key
expects a list, but IMHO it should actually raise an exception (fail fast) with an informative error message telling the user the schema was not found in the configuration.PS.: Another thing that I wanted to ask is: If Kaffy needs a graph of all dependencies mapped as a resource, could we expose the auto setup function as a public API that can be used by users? I was omitting resources from the config to not show them in the menu, but it seems the correct way of doing that is setting the ìn_menu` flag for the resource. If Kaffy needs to know all the resources beforehand, It would help a lot if I could just iterate over the auto-discoved resources and just filter out what I don't want from the menu.
The text was updated successfully, but these errors were encountered: