Selecting a field whose type is an embedded resource raises "not found in resource lookup"
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend
Research direction
Start in lib/ash_lua/fields.ex, especially select_for_type/3 around lines 254–257, and trace how ctx.lookup is built from resource_lookup/1 and how the manifest stores embedded definitions in manifest.types. Reproduce with the listed embedded attribute, union, or array case and inspect selection of a sub-field. Done means selecting embedded values returns them without lookup errors, with the suggested default public attributes and no extra select or load.
Written by the indexing model from the issue text.
Description
Seen on 0.2.3 and still on main (878d144e).
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
profilof 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.
- Dominant language
- Elixir
- Stars
- 15
- Forks
- 5
- Avg merge
- 2h 16m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ash-project/ash_lua
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ash-project/ash_lua#24 ·
All issues in ash-project/ash_lua
Similar issues
-
@swmansion/popcorn: published .d.ts files lack extensions on relative imports, breaking moduleResolution node16/nodenextPossibly taken @Huyvux12 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
software-mansion/popcorn#929 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ash-project/ash#3127 ·
Maintainers usually reply within 1 day
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History pageOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
hexlet-codebattle/codebattle#2375 ·
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wintermeyer/vutuv#2388 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100