{"record":{"id":"b03678c3c2a3c5b4","repo":"badges/shields","slug":"unsupported-query","errorCode":null,"errorMessage":"unsupported query","messagePattern":"unsupported query","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"services/dynamic/dynamic-xml.service.js","lineNumber":124,"sourceCode":"      typeof values === 'string' ||\n      typeof values === 'number' ||\n      typeof values === 'boolean'\n    ) {\n      values = [values]\n    } else if (Array.isArray(values)) {\n      values = values.reduce((accum, node) => {\n        if (pathIsAttr) {\n          accum.push(node.value)\n        } else if (node.firstChild) {\n          accum.push(node.firstChild.data)\n        } else {\n          accum.push(node.data)\n        }\n\n        return accum\n      }, [])\n    } else {\n      throw new InvalidResponse({\n        prettyMessage: 'unsupported query',\n      })\n    }\n\n    if (!values.length) {\n      throw new InvalidResponse({ prettyMessage: 'no result' })\n    }\n\n    return { values }\n  }\n\n  async handle(_namedParams, { url, query: pathExpression, prefix, suffix }) {\n    const { buffer, res } = await this._request({\n      url,\n      options: {\n        headers: { Accept: 'application/xml, text/xml' },\n        timeout: { request: 3500 },\n      },","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/dynamic/dynamic-xml.service.js#L106-L142","documentation":"This InvalidResponse is thrown when the xpath evaluation returned a value that is neither a string, number, boolean, nor a node list — i.e. the pathExpression selected something the service does not know how to reduce to a badge value. The service only supports queries yielding text nodes/strings and flat node arrays; anything else is 'unsupported query'.","triggerScenarios":"Using an XPath expression that selects a non-extractable construct — e.g. a namespace node, a comment-only/complex node selection not covered by the service's node-type handling, or expressions returning node-sets of a type the accum-reduce path doesn't handle (the else branch after checking strings/numbers/booleans/node lists).","commonSituations":"Selecting elements expecting attribute extraction the service doesn't implement; using expressions returning comment/processing-instruction nodes; complex queries returning mixed node types; attempting to select the document node itself.","solutions":["End the path expression with /text() so it yields string/text-node values (e.g. //version/text()).","Select a single simple value rather than complex/ambiguous node sets.","If you need an attribute, use /@attr — and verify the service's attribute handling supports your expression, otherwise restructure the query.","Test the expression with a plain XPath 1.0 evaluator to confirm it returns a string or node list."],"exampleFix":"// before\npath=//project    (selects whole element node set the service can't reduce)\n// after\npath=//project/version/text()","handlingStrategy":"validation","validationCode":"// ensure the expression terminates in a text() or simple value selection\nfunction isValueXPath(expr) {\n  return /(^|\\/)text\\(\\)$/.test(expr) || /@\\w+$/.test(expr) || /string\\(/.test(expr);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const value = await dynamicXml({ url, path });\n} catch (err) {\n  if (err.message === 'unsupported query') {\n    // rewrite path to end in /text()\n  } else {\n    throw err;\n  }\n}","preventionTips":["End path expressions with /text() (or select a simple attribute) so the result is a string.","Avoid selecting whole element nodes, comments, or the document node as the badge value.","Verify with a plain XPath evaluator that the expression returns a string or flat node list."],"tags":["xpath","unsupported-query","dynamic-badge","upstream-response"],"backgroundTag":"unsupported-xpath-query","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}