loopbackio / loopbackio/loopback-next

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

Offen
#10,637 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
TypeScript
Sterne
5.1k
Forks
1.1k
Ø Merge
2 T. 21 Std.
Gemergte PRs (30 T.)
27

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die verknüpfte db-test-Reproduktion auszuführen, und untersuche die generierte DataSource, das model, den controller, das repository und den Aufruf this.dbTestRepository.find(filter). Verfolge, wie das mit Cosmos DB Mongo-kompatible Backend den generierten Filter und die Order-by-Anfrage verarbeitet; abgeschlossen ist die Aufgabe, wenn GET /db-tests das erwartete Daten-Array statt eines 500-Fehlers zurückgibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
mongodb, nodejs, typescript
Bereich
backend, database
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.