{"record":{"id":"8a35433b1f19ca4d","repo":"badges/shields","slug":"no-result-8a3543","errorCode":null,"errorMessage":"no result","messagePattern":"no result","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"services/dynamic/json-path.js","lineNumber":64,"sourceCode":"      let values\n      try {\n        values = jp({ json: data, path: pathExpression, eval: false })\n      } catch (e) {\n        const { message } = e\n        if (\n          message.includes('prevented in JSONPath expression') ||\n          e instanceof TypeError\n        ) {\n          throw new InvalidParameter({\n            prettyMessage: 'query not supported',\n          })\n        } else {\n          throw e\n        }\n      }\n\n      if (!values || !values.length) {\n        throw new InvalidResponse({ prettyMessage: 'no result' })\n      }\n\n      return renderDynamicBadge({ value: values, prefix, suffix })\n    }\n  }\n","sourceCodeStart":46,"sourceCodeEnd":70,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/dynamic/json-path.js#L46-L70","documentation":"After evaluating the JSONPath query against the fetched JSON, the service checks the result array. If the query matched nothing (undefined or empty), it throws InvalidResponse with prettyMessage 'no result' — the upstream JSON was reachable but contained no data at the queried path.","triggerScenarios":"Dynamic JSON badge (/badge/dynamic/json) where the url returns valid JSON but no element matches the query: wrong key names, data moved to a different path, empty arrays/objects in the response.","commonSituations":"Upstream API schema changes; querying $.items[0].version when items is empty; case-sensitive key typos; response envelope wrapped differently (e.g. data.result vs result).","solutions":["Fetch the url manually and run the JSONPath query against the actual payload to find the correct path","Update the query to the new schema location of the value","Guard against empty collections by pointing at an endpoint that guarantees the key exists","Add prefix/suffix only after a match is confirmed"],"exampleFix":"// before\n/badge/dynamic/json?url=https://api.example.com/pkg&query=$.data.latest\n// after (API returns { result: { latest: ... } })\n/badge/dynamic/json?url=https://api.example.com/pkg&query=$.result.latest","handlingStrategy":"validation","validationCode":"const jsonpath = require('jsonpath')\nasync function queryHasResult(url, query) {\n  const res = await fetch(url)\n  const json = await res.json()\n  const values = jsonpath.query(json, query)\n  return Array.isArray(values) && values.length > 0\n}\n// check before displaying the badge","typeGuard":null,"tryCatchPattern":"try {\n  const badge = await getJsonPathBadge({ url, query, prefix, suffix })\n} catch (e) {\n  if (e.prettyMessage === 'no result') {\n    renderPlaceholderBadge('value unavailable')\n  } else throw e\n}","preventionTips":["Fetch the endpoint JSON and verify the exact key path (mind case sensitivity)","Array-index queries like $.items[0].x fail on empty arrays — check the collection first","Re-verify badge queries after upstream API schema changes","Use jsonpath online evaluators with a live response sample"],"tags":["jsonpath","json","badge","invalid-response"],"backgroundTag":"jsonpath-query-no-result","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}