update/destroy on a missing id returns error class "unknown", while get returns "invalid"
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- elixir
- Domain
- backend-api-design
Research direction
Start with AshLua.Runtime.unwrap_bulk_result/3 in lib/ash_lua/runtime.ex and AshLua.Encoder.error_class/1 in lib/ash_lua/encoder.ex, then trace how get encodes the same NotFound error. Convert or classify the bulk error consistently so missing IDs from update and destroy report class "invalid" like get; verify all three operations return the same class.
Written by the indexing model from the issue text.
Description
Seen on 0.2.3 and still on main (878d144e).
A get on an id that doesn't exist returns an error whose class is "invalid". An update or destroy on an id that doesn't exist returns class == "unknown". A script that branches on err.class therefore treats the same "not found" in two different ways.
Cause
AshLua.Runtime.unwrap_bulk_result/3 (lib/ash_lua/runtime.ex ~1180-1194) returns a bare Ash.Error.Query.NotFound for an empty :success bulk result. Its error branch can also return a list of errors. AshLua.Encoder.error_class/1 (lib/ash_lua/encoder.ex ~472-477) only matches the top-level error-class structs (Ash.Error.Invalid, Forbidden, …), so the bare NotFound falls through to "unknown".
Repro
- Take any resource with an update action exposed on the Lua surface.
- Run
local ok, err = x.update({ input = { id = "<a uuid that does not exist>", ... } }). err.classis"unknown", whilex.getwith the same id gives"invalid".
Suggested fix
Run the error through Ash.Error.to_error_class/1 in encode_error/1 (or in unwrap_bulk_result/3) before classifying it. NotFound then becomes an Ash.Error.Invalid (class "invalid"), the same as get.
- 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 3/5 1-2 days Newbie friendliness 72/100
ash-project/ash_lua#23 ·
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