Issue with request:parameter-map and repeated query parameters

Saturday, 15 November 2025 · 3 messages
TH
Tom De Herdt15 Nov 2025 17:50 #
Hello, I’ve encountered an issue with the new request:parameter-map function in BaseX. It throws an error when called with a query string that contains repeated parameters, such as ?a=1&a=2: [SERE0023] Value has more than one item. Is this behavior expected? As far as I know, query parameters may be repeated. For example, this can occur when submitting a form with checkboxes using the GET method. Additionally, JavaScript provides the URLSearchParams.getAll(<name>) method, which returns an array of values for a given parameter <name>. Wouldn't it be more logical for request:parameter-map to also return an array in such cases? I’ve tested this issue with BaseX 12 on Windows, using the following RESTXQ function: declare %rest:GET %rest:path("test") %output:method("json") function page:test() { request:parameter-map() }; Any insights are appreciated. Regards, Tom De Herdt
CG
Christian Grün15 Nov 2025 19:22 #
Hi Tom, The error is caused by your intent to serialize the map as JSON. You should get a successful response if you replace 'json' with 'basex' or 'adaptive'. If you want to output data as JSON, it is handy indeed if value lists are represented as arrays. However, most features of XQuery treat sequences as first-class citizens, and JSON serialization is just one use case. Hope this helps, Christian ____________________________________ Dr. Christian Grün, BaseX GmbH, basexgmbh.de<http://basexgmbh.de/> |-- Firmensitz: Obere Laube 73, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: +49 7531 28 28 676, Mail: info at basexgmbh.de<mailto:info at basexgmbh.de> <https://aka.ms/AAb9ysg>
Quoted text · Tom De Herdt · 28 lines
From: Tom De Herdt via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Sent: Saturday, November 15, 2025 5:50:27 PM To: BaseX <basex-talk at mailman.uni-konstanz.de> Subject: [basex-talk] Issue with request:parameter-map and repeated query parameters Hello, I’ve encountered an issue with the new request:parameter-map function in BaseX. It throws an error when called with a query string that contains repeated parameters, such as ?a=1&a=2: [SERE0023] Value has more than one item. Is this behavior expected? As far as I know, query parameters may be repeated. For example, this can occur when submitting a form with checkboxes using the GET method. Additionally, JavaScript provides the URLSearchParams.getAll(<name>) method, which returns an array of values for a given parameter <name>. Wouldn't it be more logical for request:parameter-map to also return an array in such cases? I’ve tested this issue with BaseX 12 on Windows, using the following RESTXQ function: declare %rest:GET %rest:path("test") %output:method("json") function page:test() { request:parameter-map() }; Any insights are appreciated. Regards, Tom De Herdt
TH
Tom De Herdt15 Nov 2025 21:28 #
Hi Christian, OK, I understand now. The issue occurred in a JSON API that outputs simple maps without sequence values. I lost sight of the distinction between maps and JSON objects, and mistakenly assumed the problem was with the function rather than with serialization. Simply looking up the actual error code (or paying attention to its SERE prefix) should have kept me from asking in the first place. Sorry for the noise. But thank you for the quick reply. Best, Tom
Quoted text · Christian Grün · 60 lines
On 11/15/2025 7:22 PM, Christian Grün wrote: > Hi Tom, > > The error is caused by your intent to serialize the map as JSON. You > should get a successful response if you replace 'json' with 'basex' or > 'adaptive'. > > If you want to output data as JSON, it is handy indeed if value lists > are represented as arrays. However, most features of XQuery treat > sequences as first-class citizens, and JSON serialization is just one > use case. > > Hope this helps, > Christian > > ____________________________________ > > Dr. Christian Grün, BaseX GmbH, basexgmbh.de <http://basexgmbh.de/> > |-- Firmensitz: Obere Laube 73, 78462 Konstanz > |-- Registergericht Freiburg, HRB:708285, Geschäftsführer: > | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > `-- Phone:+49 7531 28 28 676, Mail: info at basexgmbh.de > ------------------------------------------------------------------------ > *From:* Tom De Herdt via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> > *Sent:* Saturday, November 15, 2025 5:50:27 PM > *To:* BaseX <basex-talk at mailman.uni-konstanz.de> > *Subject:* [basex-talk] Issue with request:parameter-map and repeated > query parameters > Hello, > > I’ve encountered an issue with the new request:parameter-map function in > BaseX. It throws an error when called with a query string that contains > repeated parameters, such as ?a=1&a=2: > > [SERE0023] Value has more than one item. > > Is this behavior expected? As far as I know, query parameters may be > repeated. For example, this can occur when submitting a form with > checkboxes using the GET method. Additionally, JavaScript provides the > URLSearchParams.getAll(<name>) method, which returns an array of values > for a given parameter <name>. > > Wouldn't it be more logical for request:parameter-map to also return an > array in such cases? > > I’ve tested this issue with BaseX 12 on Windows, using the following > RESTXQ function: > > declare > %rest:GET > %rest:path("test") > %output:method("json") > function page:test() { > request:parameter-map() > }; > > Any insights are appreciated. > > Regards, > Tom De Herdt

⚡Generated with XQuery