The problem is obviously the unique partial index on the ids.code field
com.mongodb.MongoCommandException:
Command failed with error 11000 (DuplicateKey):
'E11000 duplicate key error collection: mydb.mycollection index:
ids.code_1 dup key: { ids.code: null }' on server 127.0.0.1:27018.
The full response is {"ok": 0.0, "errmsg": "E11000 duplicate key error collection: mydb.mycollection index: ids.code_1 dup key: { ids.code: null }", "code": 11000, "codeName": "DuplicateKey", "keyPattern": {"ids.code": 1.0}, "keyValue": {"ids.code": null}}
{
"v" : 2,
"unique" : true,
"key" : {
"ids.code" : 1.0
},
"name" : "ids.code_1",
"partialFilterExpression" : {
"ids.code" : {
"$exists" : true
}
}
}
Strangely, RESTHeart returns an HTTP 200 code
In 5.x (including latest release 5.4.7) we have two bugs:
1) the error message {"http status code":409,"http status description":"Conflict","message":"The ETag must be provided using the 'If-Match' header"}
is wrong. In 6.x it is correctly {"http status code":409,"http status description":"Conflict","message":"Duplicate key error (insert with existing _id, update a document not matching specified filter or unique index violation)"}
2) a conflict due to a dup key when passing the ETag returns 200 and it is wrong. In 6.x it correctly returns 409
Thanks @ujibang
If it helps, I put my http file (JetBrains http Client file) here
Wrong response code and message for PATCH on error due to duplicate key
Greetings!
I put RESTHeart behind an Apache reverse proxy under a new location called /api
. All tests including https://bo.mydomain.org/api/ping
work as expected. However, when I try to access
https://bo.mydomain.org/api/myBucket.files
from a browser (other than Firefox), I get a 401 after entering the (admin/secret) username/password. The logs print:
o.r.s.mechanisms.DigestAuthMechanism - The URI in digest token does not match the request URI
I tried Chrome, Edge, Safari, all with 401. Firefox, curl, Postman work as expected.
Do I need to do extra setup on RESTHeart to inform it of the new base_url https://bo.mydomain.org/api/
?
Thank you!
We configured mongo-mounts
this way
mongo-mounts:
- what: /foo
where: /api
created a files bucket and uploaded there a file
we then put the url in the browser http://localhost:8081/api/my.files/6176cdb7f3ccde248345ffa3/binary
the browser login window pops up and providing the correct credentials, the browser display the file (in our test case it's an image)
17:38:34.769 [XNIO-1 task-1] DEBUG o.r.plugins.security.AuthMechanism - digestAuthMechanism -> AUTHENTICATED
Hi @ujibang Thank you for the prompt response. I clear the browser cache between tests and use private / incognito modes. This is what I did. In my Apache conf file, I have a section that looks like:
<VirtualHost bo.mydomain.org:443>
ServerName bo.mydomain.org
# SSL and other conf
<Proxy balancer://restheart>
BalancerMember http://10.0.0.1:32111 route=route1 keepalive=On ping=1 ttl=60
ProxySet lbmethod=bytraffic
ProxySet stickysession=ROUTEID
</Proxy>
<Location /api>
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
ProxyPass balancer://restheart
</Location>
</VirtualHost>
I run restheart as a Docker image, available on http://10.0.0.1:32111
Like I said, curl, Postman, Firefox, all work as expected. Chrome and Edge seem to misbehave.
Hello. I'm loving the RESTHeart Container. I run it in a single-node Kubernetes cluster to play with. When I view the logs, I noticed that the logs are missing a date!
11:50:38.504 [XNIO-1 task-2] INFO org.restheart.handlers.RequestLogger - PUT http://api/test from /10.0.0.1:52431 => status=401 elapsed=1ms contentLength=0
When viewing the console from within the DashboardUI, I see the date:
2021-12-06T11:50:38.504764642+03:00 11:50:38.504 [XNIO-1 task-2] [34mINFO [0;39m org.restheart.handlers.RequestLogger - PUT http://api/test from /10.0.0.1:52431 => status=[31;1m401[m elapsed=1ms contentLength=0
So I'm guessing the ansi / control sequence are preventing the date from being printed.
Do you have the same issue when running in a container? Do you have a suggestion to fix the issue? Thank you!!
H @jdimi_gitlab I double checked, I think that you can use graphql type Long
to map mongodb type BsonInt64
8d6acdb
that shouyld fix it . You can try the snapshot build. See how at https://github.com/SoftInstigate/restheart/blob/master/README.md#snapshot-builds
{
"_id": "testLong",
"descriptor": {
"name": "TestLong",
"description": "GraphQL App to test Long scalar",
"enabled": true,
"uri": "testLong"
},
"schema": "type Test{ _id: ObjectId n: Long } type Query { all: [Test] }",
"mappings": {
"Test": {
},
"Query": {
"all": {
"db": "restheart",
"collection": "test"
}
}
}
}
test
documents like{
"n": {
"$numberLong": "2398239058230985"
}
}