Reputation: 555
I have created the following function in mongodb atlas:
// This function is the endpoint's request handler.
exports = function({ query, headers, body}, response) {
// Data can be extracted from the request as follows:
const docs = context.services
.get("mongodb-atlas")
.db("tennisRankings")
.collection("UTR14Female")
.find({utr: {$exists:true}})
.toArray();
return docs
};
This is paired up with an Mongo Atlas endpoint. I receive the following error when I request:
HTTP/1.1 500 Internal Server Error
content-encoding: gzip
content-type: application/json
strict-transport-security: max-age=31536000; includeSubdomains;
vary: Origin
x-appservices-request-id: 6467707e967219ab3bf8ce7e
x-envoy-max-retries: 0
x-frame-options: DENY
date: Fri, 19 May 2023 12:50:06 GMT
content-length: 189
x-envoy-upstream-service-time: 164
server: mdbws
connection: close
{
"error": "error processing request",
"error_code": "InternalServerError",
"link": "https://realm.mongodb.com/groups/64620fa04a4f24495a3299fd/apps/6466ca1190b5521afdd68636/logs?co_id=6467707e967219ab3bf8ce7e"
}
However, when I change the find()
to findOne()
, I retrieve the first record successfully. The working code is below:
// This function is the endpoint's request handler.
exports = function({ query, headers, body}, response) {
// Data can be extracted from the request as follows:
const docs = context.services
.get("mongodb-atlas")
.db("tennisRankings")
.collection("UTR14Female")
.findOne()
return docs;
};
I have also tried:
.find({})
The linked error log output is below:
Error:
failed to set response
{
"name": "getUTR",
"arguments": [
{
"query": {},
"headers": {
"X-Cluster-Client-Ip": [
"114.77.49.60"
],
"X-Forwarded-Proto": [
"https"
],
"X-Forwarded-Client-Cert": [
"By=spiffe://xgen-prod/ns/baas-prod/sa/baas-main;Hash=c68c5aa61293af7317ce95a81111deb355d7f6acdfabeb775e95a468d14f947a;Subject=\"O=MongoDB\\, Inc.,CN=lb-b\";URI=spiffe://xgen-prod/ns/vm-prod/sa/lb-b"
],
"X-Forwarded-For": [
"114.77.49.60"
],
"X-Envoy-External-Address": [
"114.77.49.60"
],
"X-Request-Id": [
"f0453022-268c-448d-8056-72b54252fce4"
],
"Postman-Token": [
"8c57ce45-12c6-47bf-a476-c5588c9d29ff"
]
}
},
{}
]
}
Function Call Location:
AU
Endpoint Query Arguments:
{}
Endpoint Headers:
{
"X-Forwarded-Proto": [
"https"
],
"X-Forwarded-Client-Cert": [
"By=spiffe://xgen-prod/ns/baas-prod/sa/baas-main;Hash=c68c5aa61293af7317ce95a81111deb355d7f6acdfabeb775e95a468d14f947a;Subject=\"O=MongoDB\\, Inc.,CN=lb-b\";URI=spiffe://xgen-prod/ns/vm-prod/sa/lb-b"
],
"X-Forwarded-For": [
"114.77.49.60"
],
"X-Envoy-External-Address": [
"114.77.49.60"
],
"X-Request-Id": [
"f0453022-268c-448d-8056-72b54252fce4"
],
"Postman-Token": [
"8c57ce45-12c6-47bf-a476-c5588c9d29ff"
],
"X-Cluster-Client-Ip": [
"114.77.49.60"
]
}
Any assistance is appreciated.
Upvotes: 0
Views: 445