Strictre type checks on RestXQ

Wednesday, 20 May 2026 · 3 messages · last reply 21 May 2026
ML
Marco Lettere20 May 2026 18:57 #
Hello all, I have a code similar to [1] and used to call it like: curl -X POST "https://myservice.local?compress=false". It worked. Yesterday I moved to official Basex 12.3 version and started getting the following error: *Value of 'compress' must be of type xs:boolean, supplied: "false". (hint: ....)* Is this a recent implementation change that enforces this type-check? I've not been able to identify the changes in the code base. Apparently, I can fix this by changing 'false' to false() in the annotation but do you have any idea whether this will be back compatible to older basex versions? Thanks! Marco. [1] declare %rest:path("store") %rest:POST %rest:query-param("compress", "{$compress}", 'false') %rest:produces("application/xml") function _:store($compress as xs:boolean) { () };
CG
Christian Grün21 May 2026 09:16 #
Hi Marco, Ci hai beccati, the interpretation of query parameters has changed with 12.3: Defaults will no longer be cast to the parameter type anymore, as we found the underlying mechanism to be too idiosyncratic and error-prone. As you have already discovered, true() and false() are now allowed and supported as annotation values. If you need to make your code backward-compatible, you can use either use an optional type for values whose Boolean value is false (this includes false(), 0, empty strings)… declare %rest:path('test') %rest:query-param('b', '{$b}') function abcde($b as xs:boolean?) { (: and so on :) }; …or use strings and do explicit casts afterwards.
declare
  %rest:path('test')
  %rest:query-param('b', '{$b}', 'false')
function abcde($b as xs:string) {
  if(xs:boolean($b)) { (: and so on :) }
};
Spero che aiuti, Christian
Quoted text · Marco Lettere · 21 lines
Von: Marco Lettere via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Mittwoch, 20. Mai 2026 18:57 An: basex-talk at mailman.uni-konstanz.de Betreff: [basex-talk] Strictre type checks on RestXQ Hello all, I have a code similar to [1] and used to call it like: curl -X POST "https://myservice.local?compress=false"<https://myservice.local?compress=false>. It worked. Yesterday I moved to official Basex 12.3 version and started getting the following error: Value of 'compress' must be of type xs:boolean, supplied: "false". (hint: ....) Is this a recent implementation change that enforces this type-check? I've not been able to identify the changes in the code base. Apparently, I can fix this by changing 'false' to false() in the annotation but do you have any idea whether this will be back compatible to older basex versions? Thanks! Marco. [1] declare %rest:path("store") %rest:POST %rest:query-param("compress", "{$compress}", 'false') %rest:produces("application/xml") function _:store($compress as xs:boolean) { () };
ML
Marco Lettere21 May 2026 09:46 #
Grazie Christian! Saluti, M.
Quoted text · Christian Grün · 56 lines
On 5/21/26 09:16, Christian Grün wrote: > Hi Marco, > > Ci hai beccati, the interpretation of query parameters has changed with 12.3: Defaults will no longer be cast to the parameter type anymore, as we found the underlying mechanism to be too idiosyncratic and error-prone. > > As you have already discovered, true() and false() are now allowed and supported as annotation values. If you need to make your code backward-compatible, you can use either use an optional type for values whose Boolean value is false (this includes false(), 0, empty strings)… > > declare > %rest:path('test') > %rest:query-param('b', '{$b}') > function abcde($b as xs:boolean?) { (: and so on :) }; > > …or use strings and do explicit casts afterwards. > > declare > %rest:path('test') > %rest:query-param('b', '{$b}', 'false') > function abcde($b as xs:string) { > if(xs:boolean($b)) { (: and so on :) } > }; > > Spero che aiuti, > Christian > ________________________________________ > > Von: Marco Lettere via BaseX-Talk<basex-talk at mailman.uni-konstanz.de> > Gesendet: Mittwoch, 20. Mai 2026 18:57 > An:basex-talk at mailman.uni-konstanz.de > Betreff: [basex-talk] Strictre type checks on RestXQ > > Hello all, > > I have a code similar to [1] and used to call it like: curl -X POST"https://myservice.local?compress=false"<https://myservice.local?compress=false>. It worked. > > Yesterday I moved to official Basex 12.3 version and started getting the following error: > > Value of 'compress' must be of type xs:boolean, supplied: "false". (hint: ....) > > Is this a recent implementation change that enforces this type-check? I've not been able to identify the changes in the code base. > > Apparently, I can fix this by changing 'false' to false() in the annotation but do you have any idea whether this will be back compatible to older basex versions? > > Thanks! > > Marco. > > [1] > > declare > %rest:path("store") > %rest:POST > %rest:query-param("compress", "{$compress}", 'false') > %rest:produces("application/xml") > function _:store($compress as xs:boolean) { > () > };

⚡Generated with XQuery