badges/shields · error · InvalidResponse

unsupported query

Error message

unsupported query

What it means

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'.

Source

Thrown at services/dynamic/dynamic-xml.service.js:124

      typeof values === 'string' ||
      typeof values === 'number' ||
      typeof values === 'boolean'
    ) {
      values = [values]
    } else if (Array.isArray(values)) {
      values = values.reduce((accum, node) => {
        if (pathIsAttr) {
          accum.push(node.value)
        } else if (node.firstChild) {
          accum.push(node.firstChild.data)
        } else {
          accum.push(node.data)
        }

        return accum
      }, [])
    } else {
      throw new InvalidResponse({
        prettyMessage: 'unsupported query',
      })
    }

    if (!values.length) {
      throw new InvalidResponse({ prettyMessage: 'no result' })
    }

    return { values }
  }

  async handle(_namedParams, { url, query: pathExpression, prefix, suffix }) {
    const { buffer, res } = await this._request({
      url,
      options: {
        headers: { Accept: 'application/xml, text/xml' },
        timeout: { request: 3500 },
      },

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. End the path expression with /text() so it yields string/text-node values (e.g. //version/text()).
  2. Select a single simple value rather than complex/ambiguous node sets.
  3. If you need an attribute, use /@attr — and verify the service's attribute handling supports your expression, otherwise restructure the query.
  4. Test the expression with a plain XPath 1.0 evaluator to confirm it returns a string or node list.

Example fix

// before
path=//project    (selects whole element node set the service can't reduce)
// after
path=//project/version/text()
Defensive patterns

Strategy: validation

Validate before calling

// ensure the expression terminates in a text() or simple value selection
function isValueXPath(expr) {
  return /(^|\/)text\(\)$/.test(expr) || /@\w+$/.test(expr) || /string\(/.test(expr);
}

Try / catch

try {
  const value = await dynamicXml({ url, path });
} catch (err) {
  if (err.message === 'unsupported query') {
    // rewrite path to end in /text()
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30). Data as JSON: /api/errors/b03678c3c2a3c5b4. Report an issue: GitHub.