POST /api/collections returns 500 instead of 400 for ADM validation failures
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 86/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
调研方向
从 collections-controller.js:create() 入手,以 POST /api/collections 的复现作为入口,检查 BaseService.create() 的校验错误是如何被处理的。保留结构化的 400 校验详情,并验证不受支持的 x_mitre_domains 和空的 x_mitre_contents 会在不持久化的情况下返回 400。
由索引模型根据 Issue 内容生成。
描述
Description
Invalid collection payloads return a generic HTTP 500 instead of a validation response identifying the rejected fields.
Observed on REST API 4.24.0, commit 69b37fe769e6abe7675d413451a8361aecc36bea.
Reproduction
- Prepare a valid
x-mitre-collectionpayload containing at least one existing object revision inx_mitre_contents. - Add
"x_mitre_domains": ["enterprise-attack"]to itsstixobject. - POST the payload to
/api/collections.
Actual: HTTP 500:
Unable to create collection. Server error.
Expected: HTTP 400 with structured ADM validation details indicating that x_mitre_domains is an unrecognized collection field.
Removing x_mitre_domains allows the nonempty collection to return 201 and persist successfully. Explicitly empty x_mitre_contents also produces the same misleading 500.
Cause and suggested fix
BaseService.create() throws ValidationError, but collections-controller.js:create() maps every exception except DuplicateIdError to a generic 500. The log contains:
Failed with error: ValidationError: ADM validation failed
Preserve the normal validation-error handling and field-level details. Add regressions asserting 400 and no persistence for unsupported fields and empty contents.
These requests did not crash the REST process; REST and MongoDB remained healthy during verification.
- 主要语言
- JavaScript
- 星标
- 56
- 派生
- 18
- 平均合并
- 19 小时 39 分钟
- 30 天内合并 PR
- 7
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mitre-attack/attack-workbench-rest-api 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 86/100
-
Add ADM validation bypass for server-controlled fields on non-compliant objects可能已有人在做 @seansica 于 23 天前认领。 未关闭
mitre-attack/attack-workbench-rest-api#517 · 已指派 1 人 ·
-
难度 3/5 1-2 天 新手友好度 74/100
mitre-attack/attack-workbench-rest-api#512 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 68/100
查看 mitre-attack/attack-workbench-rest-api 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
obsidianmd/obsidian-developer-docs#281 ·
维护者通常 4 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
FriendsOfFlarum/synopsis#16 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
Fei-Away/Codex-Dream-Skin#449 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
sysprog21/codetrial#604 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
outline/outline#14489 · 1 条评论 ·
维护者通常 1 天内回复