Unexpected error `Enumerable not implemented for nil of type Atom`
- Langage dominant
- Elixir
- Étoiles
- 1.4k
- Forks
- 171
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
**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 the `resources` 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 a `belongs_to :bar, Bar` relationship and I only add `Foo` and not `Bar` to the `resources` 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 because `get_context_for_schema` can return `nil` and `get_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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.