loopbackio / loopbackio/loopback-next
Getting 500 error from cosmosdb "The index path corresponding to the specified order-by item is excluded." from find query.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
### Describe the bug
Created a new app from loopback 4 cli and created a new DataSource, model, controller and repository.
Query used for the apis is this.dbTestRepository.find(filter).
After using the get api from that app facing below error.
GET localhosts:3000/db-tests
Current Output:
Error
`Request GET /db-tests
Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 95292a49-f12c-44bc-bc0b-95d5a2272e5b; Reason: (Message: {"Errors": ["The index path corresponding to the specified order-by item is excluded."]}
`
Expected Output:
Should return the data array output
[{
"_id": {
"$oid": "66cdadb18cd33676522f817f"
},
"name": "test",
"description": "test",
"tags": "test"
}]
### Logs
```shell
Request GET /db-tests?filter=%7B%0A%20%20%22offset%22%3A%200%2C%0A%20%20%22limit%22%3A%20100%2C%0A%20%20%22skip%22%3A%200%2C%0A%20%20%22order%22%3A%20%22string%22%2C%0A%20%20%22where%22%3A%20%7B%0A%20%20%20%20%22additionalProp1%22%3A%20%7B%7D%0A%20%20%7D%2C%0A%20%20%22fields%22%3A%20%7B%0A%20%20%20%20%22id%22%3A%20true%2C%0A%20%20%20%20%22name%22%3A%20true%2C%0A%20%20%20%20%22description%22%3A%20true%2C%0A%20%20%20%20%22tags%22%3A%20true%0A%20%20%7D%0A%7D failed with status code 500. MongoError: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 95292a49-f12c-44bc-bc0b-95d5a2272e5b; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 95292a49-f12c-44bc-bc0b-95d5a2272e5b; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: 95292a49-f12c-44bc-bc0b-95d5a2272e5b; Reason: (Message: {"Errors":["The index path corresponding to the specified order-by item is excluded."]}
ActivityId: 95292a49-f12c-44bc-bc0b-95d5a2272e5b, Request URI: /apps/a793b7f7-4246-4309-81ba-ad4af333120e/services/84dedc99-0a78-4662-abfd-e1db741fce01/partitions/7cfbe97d-6c88-4bb8-bd37-3c5dca28d326/replicas/133692072018076725p/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.20348 cosmos-netstandard-sdk/3.18.0);););
at MessageStream.messageHandler (C:\Users\10691096\code\pg\db-test\node_modules\mongodb\lib\cmap\connection.js:299:20)
at MessageStream.emit (node:events:519:28)
at processIncomingData (C:\Users\10691096\code\pg\db-test\node_modules\mongodb\lib\cmap\message_stream.js:144:12)
at MessageStream._write (C:\Users\10691096\code\pg\db-test\node_modules\mongodb\lib\cmap\message_stream.js:42:5)
at writeOrBuffer (node:internal/streams/writable:564:12)
at _write (node:internal/streams/writable:493:10)
at MessageStream.Writable.write (node:internal/streams/writable:502:10)
at TLSSocket.ondata (node:internal/streams/readable:1007:22)
at TLSSocket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at TLSSocket.Readable.push (node:internal/streams/readable:390:5)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:191:23)
Request GET /db-tests?filter=%7B%0A%20%20%22offset%22%3A%200%2C%0A%20%20%22limit%22%3A%20100%2C%0A%20%20%22skip%22%3A%200%2C%0A%20%20%22order%22%3A%20%22string%22%2C%0A%20%20%22where%22%3A%20%7B%0A%20%20%20%20%22additionalProp1%22%3A%20%7B%7D%0A%20%20%7D%2C%0A%20%20%22fields%22%3A%20%7B%0A%20%20%20%20%22id%22%3A%20true%2C%0A%20%20%20%20%22name%22%3A%20true%2C%0A%20%20%20%20%22description%22%3A%20true%2C%0A%20%20%20%20%22tags%22%3A%20true%0A%20%20%7D%0A%7D failed with status code 500. MongoError: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: f58ff6ef-94c7-4406-8b43-cbdaf9902e4f; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: f58ff6ef-94c7-4406-8b43-cbdaf9902e4f; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: f58ff6ef-94c7-4406-8b43-cbdaf9902e4f; Reason: (Message: {"Errors":["The index path corresponding to the specified order-by item is excluded."]}
ActivityId: f58ff6ef-94c7-4406-8b43-cbdaf9902e4f, Request URI: /apps/a793b7f7-4246-4309-81ba-ad4af333120e/services/84dedc99-0a78-4662-abfd-e1db741fce01/partitions/7cfbe97d-6c88-4bb8-bd37-3c5dca28d326/replicas/133692072072919984s/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.20348 cosmos-netstandard-sdk/3.18.0);););
at MessageStream.messageHandler (C:\Users\10691096\code\pg\db-test\node_modules\mongodb\lib\cmap\connection.js:299:20)
at MessageStream.emit (node:events:519:28)
at processIncomingData (C:\Users\10691096\code\pg\db-test\node_modules\mongodb\lib\cmap\message_stream.js:144:12)
at MessageStream._write (C:\Users\10691096\code\pg\db-test\node_modules\mongodb\lib\cmap\message_stream.js:42:5)
at writeOrBuffer (node:internal/streams/writable:564:12)
at _write (node:internal/streams/writable:493:10)
at MessageStream.Writable.write (node:internal/streams/writable:502:10)
at TLSSocket.ondata (node:internal/streams/readable:1007:22)
at TLSSocket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at TLSSocket.Readable.push (node:internal/streams/readable:390:5)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:191:23)
```
### Additional information
_No response_
### Reproduction
https://github.com/daman-ltim/db-test
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked db-test reproduction and inspect the generated DataSource, model, controller, repository, and the this.dbTestRepository.find(filter) call. Trace how the Cosmos DB Mongo-compatible backend handles the generated filter and order-by request; done means GET /db-tests returns the expected data array instead of a 500 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, nodejs, typescript
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100