loopbackio / loopbackio/loopback-next

@param.array throws INVALID_PARAMETER_VALUE:must be string if more than 20 elements are sent

Aperta
#11,412 1 commento 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

Hello, I have an LB application running correctly in prod for couple years. I used LB4 CLI update command in my test environment, and now I'm getting INVALID_PARAMETER_VALUE:must be string error code for a REST request -that works fine in prod- when sending more than 20 values on a @param.array query param.
I assume its handled by @loopback/rest. If so, prod has v12 and my test environment v15.0.9.

1.- How to reproduce:
Having the following code in my controller:

@param({
      name: 'vendorNumbers', in: 'query', schema: { type: 'array', items: { type: 'string' } }
    }) vendorNumbers: string[],`

and calling

http://{url}/queries/selectShipments?vendorNumbers=1000294151&vendorNumbers=1000486268&vendorNumbers=1000107612&vendorNumbers=1000433151&vendorNumbers=1000353795&vendorNumbers=1000059059&vendorNumbers=1000046043&vendorNumbers=1000328740&vendorNumbers=1000353800&vendorNumbers=1000254679&vendorNumbers=1000468101&vendorNumbers=1000493680&vendorNumbers=1000483049&vendorNumbers=1000479051&vendorNumbers=1000346467&vendorNumbers=1000478186&vendorNumbers=1000428780&vendorNumbers=1000064789&vendorNumbers=1000411703&vendorNumbers=1000120574&vendorNumbers=1000056801

I get the following error:

{
	"error": {
		"statusCode": 400,
		"name": "BadRequestError",
		"message": "Invalid data [{\"0\":\"1000294151\",\"1\":\"1000486268\",\"2\":\"1000107612\",\"3\":\"1000433151\",\"4\":\"1000353795\",\"5\":\"1000059059\",\"6\":\"1000046043\",\"7\":\"1000328740\",\"8\":\"1000353800\",\"9\":\"1000254679\",\"10\":\"1000468101\",\"11\":\"1000493680\",\"12\":\"1000483049\",\"13\":\"1000479051\",\"14\":\"1000346467\",\"15\":\"1000478186\",\"16\":\"1000428780\",\"17\":\"1000064789\",\"18\":\"1000411703\",\"19\":\"1000120574\",\"20\":\"1000056801\"}] for parameter \"vendorNumbers\".",
		"code": "INVALID_PARAMETER_VALUE",
		"details": [
			{
				"path": "/0",
				"code": "type",
				"message": "must be string",
				"info": {
					"type": "string"
				}
			}
		]
	}
}

Have in mind that:

  • if I send less than 20, works fine.
  • it is not related to query length nor number of other params, cause I already tried with different lengths and number of 'other' parameters.
  • If I add maxItems of 30, I still get INVALID_PARAMETER_VALUE:must be string when sending more than 20 values.
  • During one of my tests, I set maxItems at 10, and the error changed to INVALID_PARAMETER_VALUE:must NOT have more than 10 items

Thanks

Logs

Additional information

No response

Reproduction

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 dal percorso di parsing e convalida dei parametri di query di @loopback/rest, confrontando il comportamento segnalato in v12 con v15.0.9. Riproduci la richiesta usando i 21 valori vendorNumbers ripetuti mostrati, quindi verifica perché i valori oltre 20 vengono gestiti in modo errato mentre la convalida di maxItems continua a funzionare. Il lavoro è completato quando gli array con più di 20 elementi vengono convalidati come stringhe senza regressioni negli errori maxItems.

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

Valutazione

Stack tecnologico
typescript
Ambito
api, backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.