Closed
Description
Versions
current main
(Jan, 31, 2023) - updated on (May, 2, 2023)
findAndModify
error is wrapped in WriteError
but it should not be. Also tests are passing even though the error is not correct error type. Do not rely on compat test, it incorrectly reports the error type #2545
See also #2461 (comment) and this issue number mentioned in the code.
Where?
command error is created at https://github.com/FerretDB/FerretDB/blob/main/internal/handlers/common/update.go#L907
What did you do?
test> db.foo.findAndModify({query: {}, update: {$set: {"a.b": 100}}})
test> db.fo.insert({"a":[1,2,3]})
{
acknowledged: true,
insertedIds: { '0': ObjectId("63d979a2ef882ae5c77f0da9") }
}
test> db.fo.findAndModify({query: {}, update: {$set: {"a.b": 100}}})
What did you expect to see?
Proxy response:
{
"Checksum": 0,
"FlagBits": 0,
"Sections": [
{
"Document": {
"$k": [
"ok",
"errmsg",
"code",
"codeName"
],
"ok": {
"$f": 0
},
"errmsg": "Plan executor error during findAndModify :: caused by :: Cannot create field 'b' in element {a: [ 1, 2, 3 ]}",
"code": 28,
"codeName": "PathNotViable"
},
"Kind": 0
}
]
}
What did you see instead?
FerretDB response:
Response message:
{
"Checksum": 0,
"FlagBits": 0,
"Sections": [
{
"Document": {
"$k": [
"ok",
"writeErrors"
],
"ok": {
"$f": 1
},
"writeErrors": [
{
"$k": [
"code",
"errmsg"
],
"code": 28,
"errmsg": "Cannot create field 'b' in element {a: [ 1, 2, 3 ]}"
}
]
},
"Kind": 0
}
]
}
Environment
- OS:
- Architecture:
- Version:
- Go:
- Git:
- Deployment:
- Deployment details:
To be honest, FerretDB response makes more sense to me, but let's agree/clarify how to deal with it (e.g. in tests)
Definition of Done
- find the cause of findAndModify error response wrapped in write error
- findAndModify does not wrap error in
WriteError
Metadata
Assignees
Projects
Status
Done