update/destroy on a missing id returns error class "unknown", while get returns "invalid"
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- elixir
调研方向
从 lib/ash_lua/runtime.ex 中的 AshLua.Runtime.unwrap_bulk_result/3 和 lib/ash_lua/encoder.ex 中的 AshLua.Encoder.error_class/1 开始,然后追踪 get 如何编码同一个 NotFound 错误。以一致的方式转换或分类 bulk 错误,使 update 和 destroy 中缺失的 ID 像 get 一样报告类 "invalid";验证这三个操作都返回相同的类。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Elixir
- 星标
- 15
- 派生
- 5
- 平均合并
- 2 小时 16 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ash-project/ash_lua 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 72/100
ash-project/ash_lua#23 ·
查看 ash-project/ash_lua 的全部 Issue
相似的 Issue
-
@swmansion/popcorn: published .d.ts files lack extensions on relative imports, breaking moduleResolution node16/nodenext可能已有人在做 @Huyvux12 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
software-mansion/popcorn#929 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
ash-project/ash#3127 ·
维护者通常 1 天内回复
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History page未关闭bug
难度 2/5 1-3 小时 新手友好度 74/100
hexlet-codebattle/codebattle#2375 ·
-
Bug
难度 2/5 1-3 小时 新手友好度 68/100
wintermeyer/vutuv#2388 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100