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
{{ message }}
Repository navigation
Selecting a field whose type is an embedded resource raises "not found in resource lookup" #23
A field whose type is, or contains, an embedded resource cannot be selected in fields. This covers an :embedded_resource attribute, a union whose members are embedded resources, and {:array, Embedded}. The select raises:
** (RuntimeError) Resource MyApp.SomeEmbedded not found in resource lookup
(ash) Ash.Info.Manifest.get_resource!/2
(ash_lua) AshLua.Fields.select_for_type/3 # lib/ash_lua/fields.ex ~254-257
Cause
Ash.Info.Manifest.Generator puts embedded resources in manifest.types, not manifest.resources. AshLua builds ctx.lookup from resource_lookup/1 only. Then select_for_type/3 matches kind in [:resource, :embedded_resource] and calls Manifest.get_resource!(ctx.lookup, mod), which fails for the embedded module.
Repro
Take a resource with an attribute profil of an embedded type (or a union of embedded types), exposed through a read action on the Lua surface.
Run x.list({ fields = { "id", "profil" } }), or select a sub-field of it.
It raises instead of returning the embedded value.
Suggested fix
Treat an embedded resource like a typed map. Take its definition from manifest.types (type.resource), default to all public attributes, and allow subselection. Embedded values are already loaded with the parent, so select = [] and load = [] for them.
Workaround we use
We pass our own manifest: to AshLua.Eval.run/2, with each embedded type rewritten to kind: :map.
Activity