[BUG] Empty string id is not correctly validated by forceId
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, mongodb, node.js
调研方向
使用链接的 loopback-sandbox 分支复现该问题,模型配置为 forceId: true,并使用 MongoDB 数据源。跟踪 API 创建路径以及针对显式为空的 id 的 forceId 验证;完成的标准是请求被记录的 422 ValidationError 拒绝,而不是创建数据库条目。
由索引模型根据 Issue 内容生成。
描述
Description/Steps to reproduce
- define a model with
forceId: true - associate this model to a mongodb data source
- call the API to create a new model with an explicit empty string id
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{
\"id\": \"\"
}" "http://localhost:3000/api/foos"
- this call creates a db entry with empty id and returns:
{"id": ""}
Seems related to #1453 (see my comment)
Link to reproduction sandbox
https://github.com/simonbrunel/loopback-sandbox/tree/bug/empty-id-mongodb
Expected result
{
"error": {
"name": "ValidationError",
"status": 422,
"message": "The `foo` instance is not valid. Details : `id` can't be set (value: \"\").",
"statusCode": 422,
"details": {
"context": "foo",
"codes": {
"id": [
"absence"
]
},
"messages": {
"id": [
"can't be set"
]
}
}
}
}
Additional information
node v6.11.3, Windows 10 64bit
npm ls --prod --depth 0 | grep loopback
[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
- 主要语言
- JavaScript
- 星标
- 279
- 派生
- 362
- 平均合并
- 21 小时 14 分钟
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
loopbackio/loopback-datasource-juggler 的其他 Issue
-
Breaking changes for `loopback-datasource-juggler@7` not listed anywhere可能重新可做 @dhmlau 于 158 天前认领,目前没有进行中的 PR。 未关闭bug
loopbackio/loopback-datasource-juggler#2548 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
loopbackio/loopback-datasource-juggler#2530 ·
维护者通常 1 天内回复
-
allow empty array in createAll可能已有人在做 @ajay-prajapati07 于 533 天前认领。 未关闭feature
难度 3/5 1-2 天 新手友好度 45/100
loopbackio/loopback-datasource-juggler#2409 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 25/100
loopbackio/loopback-datasource-juggler#2319 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 55/100
loopbackio/loopback-datasource-juggler#1968 ·
维护者通常 1 天内回复
查看 loopbackio/loopback-datasource-juggler 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
ipfs/ipfs-webui#2507 ·
-
Environments table lists page size 5 after 30可能已有人在做 @raus7n 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
litmuschaos/litmus#5743 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 63/100
anothaDev/luci-theme-vantage#143 ·
维护者通常 1 天内回复
-
desktop grp:admin-donors type:graphics-bug ui-admin
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
kingcharleslzy-ai/dsh-purge#282 ·
维护者通常 1 天内回复