{"record":{"id":"7a05886da4143bb3","repo":"badges/shields","slug":"threshold-must-be-branches-lines-or-functio","errorCode":null,"errorMessage":"threshold must be \"branches\", \"lines\", or \"functions\"","messagePattern":"threshold must be \"branches\", \"lines\", or \"functions\"","errorType":"exception","errorClass":"InvalidParameter","httpStatus":null,"severity":"error","filePath":"services/nycrc/nycrc.service.js","lineNumber":89,"sourceCode":"        ],\n      },\n    },\n  }\n\n  static defaultBadgeData = { label: 'min coverage' }\n\n  static render({ coverage }) {\n    return {\n      message: `${coverage.toFixed(0)}%`,\n      color: coveragePercentage(coverage),\n    }\n  }\n\n  extractThreshold(config, preferredThreshold) {\n    const { branches, lines } = config\n    if (preferredThreshold) {\n      if (!validThresholds.includes(preferredThreshold)) {\n        throw new InvalidParameter({\n          prettyMessage:\n            'threshold must be \"branches\", \"lines\", or \"functions\"',\n        })\n      }\n      if (!config[preferredThreshold]) {\n        throw new InvalidResponse({\n          prettyMessage: `\"${preferredThreshold}\" threshold missing`,\n        })\n      }\n      return config[preferredThreshold]\n    } else if (branches || lines) {\n      // We favor branches over lines for the coverage badge, if both\n      // thresholds are provided (as branches is the stricter requirement):\n      return branches || lines\n    } else {\n      throw new InvalidResponse({\n        prettyMessage: '\"branches\" or \"lines\" threshold missing',\n      })","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/nycrc/nycrc.service.js#L71-L107","documentation":"The nyc/c8 coverage service accepts an optional `preferredThreshold` query parameter to choose which coverage metric to badge. When that parameter is supplied but is not one of \"branches\", \"lines\", or \"functions\" (validThresholds), the service throws InvalidParameter with this message. It is a caller-input validation error, not an upstream-data error.","triggerScenarios":"Requesting an nycrc badge with a `preferred_threshold` (or equivalent query param) set to anything outside {branches, lines, functions}, e.g. `statements` or `coverage`.","commonSituations":"Users copying a threshold name from their nyc config that nyc supports but this badge does not (like `statements` or `lines` misspelled as `line`), or passing the config key with wrong casing.","solutions":["Change the preferredThreshold query parameter to one of: branches, lines, or functions.","Omit the parameter entirely to let the service pick branches over lines automatically.","Check spelling and casing of the parameter value in the badge URL."],"exampleFix":"// before\n<img src=\".../nycrc?preferred_threshold=statements\">\n// after\n<img src=\".../nycrc?preferred_threshold=lines\">","handlingStrategy":"validation","validationCode":"const VALID = ['branches', 'lines', 'functions']\nif (preferredThreshold && !VALID.includes(preferredThreshold)) {\n  throw new Error(`preferredThreshold must be one of ${VALID.join(', ')}`)\n}","typeGuard":"function isValidThreshold(t) {\n  return t === undefined || ['branches', 'lines', 'functions'].includes(t)\n}","tryCatchPattern":null,"preventionTips":["Whitelist-check any threshold query parameter before building the badge URL","Only use the three documented values: branches, lines, functions","Centralize badge URL construction in a helper that validates params"],"tags":["bad-input","validation","query-parameter","coverage"],"backgroundTag":"invalid-parameter-value","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}