Selecting a field whose type is an embedded resource raises "not found in resource lookup"
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- backend
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Elixir
- Estrellas
- 15
- Forks
- 5
- Merge medio
- 2 h 16 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ash-project/ash_lua
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
ash-project/ash_lua#24 ·
Todos los issues de ash-project/ash_lua
Issues similares
-
@swmansion/popcorn: published .d.ts files lack extensions on relative imports, breaking moduleResolution node16/nodenextPosiblemente ocupada @Huyvux12 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
software-mansion/popcorn#929 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
ash-project/ash#3127 ·
Los mantenedores suelen responder en 1 día
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History pageAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
hexlet-codebattle/codebattle#2375 ·
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
wintermeyer/vutuv#2388 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100