{"record":{"id":"ba2006e063d29d6d","repo":"badges/shields","slug":"no-nyc-or-c8-stanza-found","errorCode":null,"errorMessage":"no nyc or c8 stanza found","messagePattern":"no nyc or c8 stanza found","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"services/nycrc/nycrc.service.js","lineNumber":124,"sourceCode":"        prettyMessage: '\"branches\" or \"lines\" threshold missing',\n      })\n    }\n  }\n\n  async handle({ user, repo }, queryParams) {\n    const { config, preferredThreshold } = queryParams\n    let coverage\n    if (config.includes('package.json')) {\n      const pkgJson = await fetchJsonFromRepo(this, {\n        schema: pkgJSONSchema,\n        user,\n        repo,\n        branch: 'HEAD',\n        filename: config,\n      })\n      const nycConfig = pkgJson.c8 || pkgJson.nyc\n      if (!nycConfig) {\n        throw new NotFound({\n          prettyMessage: 'no nyc or c8 stanza found',\n        })\n      } else {\n        coverage = this.extractThreshold(nycConfig, preferredThreshold)\n      }\n    } else {\n      coverage = this.extractThreshold(\n        await fetchJsonFromRepo(this, {\n          schema: nycrcSchema,\n          user,\n          repo,\n          branch: 'HEAD',\n          filename: config,\n        }),\n        preferredThreshold,\n      )\n    }\n    return this.constructor.render({ coverage })","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/nycrc/nycrc.service.js#L106-L142","documentation":"The nycrc service fetches a JSON config file from the repository (package.json by default, or a named config file) and expects either a `c8` or `nyc` key holding coverage settings. If neither key exists in the parsed JSON, it throws NotFound with this message, indicating the repo does not carry an nyc/c8 coverage stanza.","triggerScenarios":"Requesting the nycrc badge for a repo whose fetched config JSON has no `nyc` and no `c8` key — including when the config filename points at a non-package JSON file without those keys.","commonSituations":"Projects using vitest/jest coverage or a separate .nycrc file while the badge reads package.json; typos like \"NYC\"; config stored under a different filename than the badge's `config` param expects.","solutions":["Add an `nyc` (or `c8`) stanza with thresholds to package.json in the target repo.","Or move/keep the config in .nycrc and pass the correct `config` filename parameter to the badge.","Confirm the repo/branch in the badge URL actually contains the config file."],"exampleFix":"// before (package.json)\n{ \"name\": \"mylib\" }\n// after\n{ \"name\": \"mylib\", \"nyc\": { \"lines\": 90, \"branches\": 80 } }","handlingStrategy":"validation","validationCode":"const pkg = require('./package.json')\nif (!pkg.nyc && !pkg.c8) {\n  throw new Error('Add an nyc or c8 stanza to package.json before using the nycrc badge')\n}","typeGuard":"function hasCoverageStanza(pkg) {\n  return pkg && typeof pkg === 'object' &&\n    (pkg.nyc != null || pkg.c8 != null)\n}","tryCatchPattern":"try {\n  const coverage = await getNycrcBadge(repo)\n} catch (e) {\n  if (e.message === 'no nyc or c8 stanza found') {\n    // repo has no coverage config: hide badge or show 'unknown'\n  } else { throw e }\n}","preventionTips":["Add the nyc/c8 config to package.json (or pass the right config filename param)","Match the badge's config parameter to where your config actually lives","Keep key names lowercase: nyc and c8, never NYC"],"tags":["config","coverage","not-found","missing-key"],"backgroundTag":"missing-config-key","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}