Model errors when using relations with the MongoDB connector cause crashes
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, mongodb
Rechercherichtung
Beginne mit dem Pfad zur Relationseinbindung in lib/include.js und der Initialisierung der Eigenschaften in lib/model.js und untersuche anschließend den Connector-Callback in lib/mongodb.js. Reproduziere eine Relationssuche, bei der versions ein Objekt statt eines Arrays ist; fertig ist es, wenn der Fehler über die HTTP-Anfrage zurückgegeben wird, anstatt dass die Anwendung abstürzt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I have relations setup with a model which includes a property similar to this:
versions: [
{
id: String
}
]
If the versions property is actually an object, rather than an array (due to an error in saving), loopback crashes when it attempts to resolve relations involving this model.
This is the error I get:
/Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/connection/base.js:245
throw message;
^
Error: Items must be an array: [object Object]
at new List (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/list.js:25:11)
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/model.js:178:39
at Array.forEach (native)
at Function.ModelClass.forEachProperty (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/model-builder.js:271:51)
at ModelConstructor.ModelBaseClass._initProperties (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/model.js:164:8)
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/dao.js:557:13
at Array.forEach (native)
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/dao.js:554:12
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/include.js:59:11
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:113:21
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:24:16
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/include.js:124:9
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:111:13
at Array.forEach (native)
at _each (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:32:24)
at Object.async.each (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:110:9)
at processIncludeItem (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/include.js:106:11)
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/include.js:57:5
at /Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:111:13
at Array.forEach (native)
at _each (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:32:24)
at Object.async.each (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:110:9)
at Function.Inclusion.include (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/include.js:56:9)
at Function.f (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/jutil.js:100:15)
at Function.f [as include] (/Users/zackbloom/s/API/node_modules/loopback-datasource-juggler/lib/jutil.js:100:15)
at /Users/zackbloom/s/API/node_modules/loopback-connector-mongodb/lib/mongodb.js:519:33
at /Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/cursor.js:163:16
at commandHandler (/Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/cursor.js:709:16)
at /Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/db.js:1846:9
at Server.Base._callHandler (/Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/connection/base.js:445:41)
at /Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/connection/server.js:468:18
at [object Object].MongoReply.parseBody (/Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at [object Object].<anonymous> (/Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/connection/server.js:426:20)
at [object Object].EventEmitter.emit (events.js:95:17)
at [object Object].<anonymous> (/Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)
at [object Object].EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/Users/zackbloom/s/API/node_modules/mongodb/lib/mongodb/connection/connection.js:339:18)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:528:21)
The error itself isn't terrible, but I'd certainly rather it be returned through the HTTP request, rather than crashing the entire app.
I've tried wrapping parts of that stack in a try block, but it looks like the mongodb connector does some fancy magic with nextTick to bypass the actual stack.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 279
- Forks
- 362
- Ø Merge
- 21 Std. 14 Min.
- Gemergte PRs (30 T.)
- 16
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus loopbackio/loopback-datasource-juggler
-
Breaking changes for `loopback-datasource-juggler@7` not listed anywhereEvtl. wieder frei @dhmlau hat das vor 158 Tagen übernommen, und es ist kein Pull Request offen. Offenbug
loopbackio/loopback-datasource-juggler#2548 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Replace deprecated util._extend with Object.assign to ensure compatibility with modern Node.jsOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
loopbackio/loopback-datasource-juggler#2530 ·
Maintainer antworten meist innerhalb von 1 Tag
-
allow empty array in createAllEvtl. vergeben @ajay-prajapati07 hat das vor 533 Tagen übernommen. Offenfeature
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
loopbackio/loopback-datasource-juggler#2409 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
loopbackio/loopback-datasource-juggler#2319 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 55/100
loopbackio/loopback-datasource-juggler#1968 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in loopbackio/loopback-datasource-juggler
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
ipfs/ipfs-webui#2507 ·
-
Environments table lists page size 5 after 30Evtl. vergeben @raus7n hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
litmuschaos/litmus#5743 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 63/100
anothaDev/luci-theme-vantage#143 ·
Maintainer antworten meist innerhalb von 1 Tag
-
desktop grp:admin-donors type:graphics-bug ui-admin
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
kingcharleslzy-ai/dsh-purge#282 ·
Maintainer antworten meist innerhalb von 1 Tag