loopbackio / loopbackio/loopback-next

Getting 500 error from cosmosdb "The index path corresponding to the specified order-by item is excluded." from find query.

Aperta
#10,637 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug
Lingua principale
TypeScript
Stelle
5.1k
Fork
1.1k
Merge medio
2g 21h
PR unite (30g)
27

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo la riproduzione collegata di db-test e ispeziona la DataSource, il model, il controller, il repository generati e la chiamata this.dbTestRepository.find(filter). Traccia il modo in cui il backend compatibile con Cosmos DB Mongo gestisce il filtro generato e la richiesta order-by; il lavoro è completato quando GET /db-tests restituisce l’array di dati previsto invece di un errore 500.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
mongodb, nodejs, typescript
Ambito
backend, database
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.