{"record":{"id":"a597b525554659a0","repo":"badges/shields","slug":"not-set-up","errorCode":null,"errorMessage":"not set up","messagePattern":"not set up","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"info","filePath":"services/gitlab/gitlab-pipeline-coverage.service.js","lineNumber":103,"sourceCode":"\n  async fetch({ project, baseUrl = 'https://gitlab.com', jobName, branch }) {\n    // Since the URL doesn't return a usable value when an invalid job name is specified,\n    // it is recommended to not use the query param at all if not required\n    jobName = jobName ? `?job=${jobName}` : ''\n    const url = `${baseUrl}/${decodeURIComponent(\n      project,\n    )}/badges/${branch}/coverage.svg${jobName}`\n    const httpErrors = httpErrorsFor('project not found')\n    return this._requestSvg({\n      schema,\n      url,\n      httpErrors,\n    })\n  }\n\n  static transform({ coverage }) {\n    if (coverage === 'unknown') {\n      throw new NotFound({ prettyMessage: 'not set up' })\n    }\n    return Number(coverage.slice(0, -1))\n  }\n\n  async handle(\n    { project },\n    { gitlab_url: baseUrl, job_name: jobName, branch },\n  ) {\n    const { message: coverage } = await this.fetch({\n      project,\n      branch,\n      baseUrl,\n      jobName,\n    })\n    return this.constructor.render({\n      coverage: this.constructor.transform({ coverage }),\n    })\n  }","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/gitlab/gitlab-pipeline-coverage.service.js#L85-L121","documentation":"The GitLab pipeline coverage service throws this NotFound error when the parsed pipeline coverage value equals the literal string 'unknown'. The upstream GitLab API returns no numeric coverage for the project/pipeline, so the service cannot render a percentage badge. This library converts the sentinel value into a 404-style 'not set up' badge instead of showing invalid data.","triggerScenarios":"Calling the GitLab pipeline coverage badge for a project whose default branch has no pipeline with coverage data, or where test coverage reporting is disabled in .gitlab-ci.yml (no coverage regex configured) so GitLab never records a coverage percentage.","commonSituations":"Projects with no CI pipelines yet; pipelines that exist but whose test job lacks the coverage keyword; the project has pipelines on other branches but none on the requested one; coverage was recently added and the pipeline has not rerun.","solutions":["Add a coverage report to the GitLab CI test job (set the coverage regex in .gitlab-ci.yml or use coverage: '/.../' on the job) and rerun the pipeline so GitLab records coverage","Verify the badge URL points at a project/branch that actually has a successful pipeline with coverage","Check the GitLab project Settings > CI/CD > Test coverage parsing is configured","If the project genuinely has no coverage, accept the badge's 'not set up' state or remove the badge"],"exampleFix":"// .gitlab-ci.yml before\ntest:\n  script: npm test\n// after\ntest:\n  script: npm test\n  coverage: '/All files[^|]*\\|[^|]*\\s+([\\d.]+)/'","handlingStrategy":"validation","validationCode":"const res = await fetch(`https://gitlab.com/api/v4/projects/${encodeURIComponent(project)}/repository/branches/${branch}`)\nconst { coverage } = await (await fetch(`https://gitlab.com/api/v4/projects/${encodeURIComponent(project)}/pipelines?ref=${branch}`)).json()[0]?.coverage !== undefined ? {} : {}\nif (!coverage) console.warn('No coverage configured for this project/branch')","typeGuard":"const hasCoverage = (c) => typeof c === 'string' && c !== 'unknown' && c.endsWith('%')","tryCatchPattern":"try {\n  const percent = GitlabPipelineCoverage.transform({ coverage })\n} catch (e) {\n  if (e.prettyMessage === 'not set up') {\n    // show 'coverage not configured' placeholder\n  } else throw e\n}","preventionTips":["Configure the coverage regex on your CI test job before adding the badge","Verify the branch has at least one pipeline with coverage before publishing the badge","Check GitLab's API coverage field via curl before embedding the badge"],"tags":["gitlab","ci","coverage","not-found"],"backgroundTag":"coverage-not-configured","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}