loopbackio / loopbackio/loopback-next

ajv request body validation regression following an upgrade to @loopback/rest 15.0.3

Offen
#11,096 2 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

Since after upgrading to @loopback/rest 15.0.3 , ajv request body validation fail when the schema contain the "discriminator" key word.

Logs
equest POST /accounts/7342217301273/actions failed with status code 500. Error: strict mode: unknown keyword: "discriminator"
    at checkStrictMode (/home/fidgi/my-app/node_modules/ajv/lib/compile/util.ts:211:28)
    at checkUnknownRules (/home/fidgi/my-app/node_modules/ajv/lib/compile/util.ts:27:22)
    at checkKeywords (/home/fidgi/my-app/node_modules/ajv/lib/compile/validate/index.ts:153:20)
    at validateFunctionCode (/home/fidgi/my-app/node_modules/ajv/lib/compile/validate/index.ts:40:5)
    at Ajv.compileSchema (/home/fidgi/my-app/node_modules/ajv/lib/compile/index.ts:163:25)
    at Ajv._compileSchemaEnv (/home/fidgi/my-app/node_modules/ajv/lib/core.ts:737:24)
    at Ajv.compile (/home/fidgi/my-app/node_modules/ajv/lib/core.ts:389:34)
    at createValidator (/home/fidgi/my-app/node_modules/@loopback/rest/src/validation/request-body.validator.ts:236:18)
    at validateValueAgainstSchema (/home/fidgi/my-app/node_modules/@loopback/rest/src/validation/request-body.validator.ts:153:16)
    at validateRequestBody (/home/fidgi/my-app/node_modules/@loopback/rest/src/validation/request-body.validator.ts:76:9)
    at buildOperationArguments (/home/fidgi/my-app/node_modules/@loopback/rest/src/parser.ts:92:28)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MySequence.handle (/home/fidgi/my-app/src/sequence.ts:51:20)
    at async HttpHandler._handleRequest (/home/fidgi/my-app/node_modules/@loopback/rest/src/http-handler.ts:115:5)
Additional information

This seems to be related to this commit

Reproduction

n/a

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 mit dem verknüpften Commit und dem Validierungsablauf in @loopback/rest/src/validation/request-body.validator.ts, insbesondere mit createValidator und validateValueAgainstSchema. Reproduziere den Fehler des request-body-Schemas mit dem discriminator-Schlüsselwort und überprüfe anschließend, dass die Validierung ihn nicht mehr ablehnt, nachdem die Regression behoben wurde.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
api, backend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

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