{"record":{"id":"5a90ad88aef4d442","repo":"badges/shields","slug":"no-result-5a90ad","errorCode":null,"errorMessage":"no result","messagePattern":"no result","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"services/dynamic/dynamic-xml.service.js","lineNumber":130,"sourceCode":"      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      },\n      httpErrors,\n      logErrors: [],\n    })\n\n    let contentType = 'text/xml'\n    if (res.headers['content-type']) {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/dynamic/dynamic-xml.service.js#L112-L148","documentation":"The dynamic XML badge service runs an XPath query against the fetched XML document. It throws InvalidResponse with prettyMessage 'no result' when the XPath expression evaluates successfully but returns an empty node set, meaning the badge cannot compute a value from the response.","triggerScenarios":"Calling the dynamic XML badge endpoint (/badge/dynamic/xml) with a url whose XML document does not contain any node matching the given XPath query (e.g. wrong element name, wrong namespace, document structure differs from expected).","commonSituations":"The upstream API changed its XML schema; the XPath uses a namespace prefix without declaring it; typo in the XPath expression; the queried element only exists in some responses (e.g. optional fields or empty lists).","solutions":["Verify the XPath query against the actual XML returned by the url (fetch it and test the expression in a tool like xmllint or an XPath evaluator)","Fix element/attribute names and namespaces in the query","Use a prefix/suffix only after confirming the query matches at least one node","If the value is legitimately optional, choose a different upstream endpoint that always exposes the data"],"exampleFix":"// before (URL whose XML has no <version> node)\n/badge/dynamic/xml?url=https://example.com/info.xml&query=//version\n// after\n/badge/dynamic/xml?url=https://example.com/info.xml&query=//project/version","handlingStrategy":"validation","validationCode":"async function hasXPathResult(url, query) {\n  const res = await fetch(url)\n  const xml = await res.text()\n  const doc = new DOMParser().parseFromString(xml, 'application/xml')\n  return doc.evaluate(`count(${query})`, doc, null, XPathResult.NUMBER_TYPE, null).numberValue > 0\n}\n// call await hasXPathResult(myUrl, myQuery) before rendering the badge","typeGuard":null,"tryCatchPattern":"try {\n  const badge = await getDynamicXmlBadge({ url, query })\n} catch (e) {\n  if (e.prettyMessage === 'no result') {\n    renderPlaceholderBadge('no data at XPath')\n  } else throw e\n}","preventionTips":["Test the XPath expression against a live copy of the XML before embedding it in a badge URL","Account for XML namespaces in the query (use local-name() or declare prefixes)","Re-test badges when the upstream API announces schema changes","Prefer querying stable, always-present elements"],"tags":["xpath","xml","badge","invalid-response"],"backgroundTag":"xpath-query-no-result","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}