{"record":{"id":"1f9f5c7251f1be46","repo":"badges/shields","slug":"no-result","errorCode":null,"errorMessage":"no result","messagePattern":"no result","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"services/dynamic/dynamic-regex.service.js","lineNumber":96,"sourceCode":"\n  static transform(buffer, search, replace, flags) {\n    // build re2 regex\n    let re2\n    try {\n      re2 = new RE2(search, flags)\n    } catch (error) {\n      if (error instanceof SyntaxError) {\n        throw new InvalidParameter({\n          prettyMessage: `Invalid re2 regex: ${error.message}`,\n        })\n      }\n      throw error\n    }\n\n    // extract value\n    const found = re2.exec(buffer)\n    if (found == null) {\n      throw new InvalidResponse({\n        prettyMessage: 'no result',\n      })\n    }\n\n    // replace if needed\n    return replace !== undefined ? found[0].replace(re2, replace) : found[0]\n  }\n\n  async handle(namedParams, { url, search, replace, flags }) {\n    this.constructor.validate(flags)\n    const { buffer } = await this._request({\n      url,\n      httpErrors,\n      logErrors: [],\n      options: { timeout: { request: 3500 } },\n    })\n    const value = this.constructor.transform(buffer, search, replace, flags)\n    return renderDynamicBadge({ value })","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/dynamic/dynamic-regex.service.js#L78-L114","documentation":"This InvalidResponse is thrown after the RE2 pattern compiled successfully but re2.exec(buffer) returns null, meaning the downloaded document (buffer) contains no substring matching the search regex. The service treats a non-match as an invalid/empty upstream response, yielding a 'no result' badge.","triggerScenarios":"The target document at the url does not contain text matching the search pattern: pattern too strict, target page changed its format, or the response is an error page (login page, 404 HTML) rather than the expected payload.","commonSituations":"Upstream site redesigns its JSON/HTML so the key no longer appears; pattern written against an example document rather than the live one; response is compressed/HTML error page; case sensitivity (missing 'i' flag).","solutions":["Fetch the url manually and verify the search pattern actually matches its current content.","Loosen the regex (add the i flag, broaden whitespace/optional segments).","Confirm the url returns the expected document (check for auth/error pages).","Test the regex locally with an RE2 engine, then update the badge URL."],"exampleFix":"// before\nsearch=\"downloads\":(\\d+)   // live JSON now: \"total_downloads\": 123\n// after\nsearch=\"total_downloads\":\\s*(\\d+)","handlingStrategy":"try-catch","validationCode":"// pre-flight: ensure the pattern matches the live document\nconst RE2 = require('re2');\nconst body = await fetch(url).then(r => r.text());\nif (!new RE2(search, flags ?? '').test(body)) throw new Error('pattern does not match live document');","typeGuard":null,"tryCatchPattern":"try {\n  const value = await dynamicRegex({ url, search });\n} catch (err) {\n  if (err.message === 'no result') {\n    // fall back to a default value or re-check the upstream page format\n  } else {\n    throw err;\n  }\n}","preventionTips":["Fetch the target url periodically and assert the pattern still matches; upstream redesigns silently break matches.","Loosen patterns (optional whitespace, i flag) to tolerate formatting changes.","Verify the url doesn't return an error/auth page instead of the expected document."],"tags":["regex","no-match","upstream-response","dynamic-badge"],"backgroundTag":"regex-no-match","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}