{"record":{"id":"81daec3e0530a57d","repo":"badges/shields","slug":"branch-not-found","errorCode":null,"errorMessage":"branch not found","messagePattern":"branch not found","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"info","filePath":"services/gitlab/gitlab-pipeline-status.service.js","lineNumber":90,"sourceCode":"\n  static render({ status }) {\n    return renderBuildStatusBadge({ status })\n  }\n\n  async fetch({ project, branch, baseUrl }) {\n    return this._requestSvg({\n      schema: badgeSchema,\n      url: `${baseUrl}/${decodeURIComponent(\n        project,\n      )}/badges/${branch}/pipeline.svg`,\n      httpErrors: httpErrorsFor('project not found'),\n    })\n  }\n\n  static transform(data) {\n    const { message: status } = data\n    if (status === 'unknown') {\n      throw new NotFound({ prettyMessage: 'branch not found' })\n    }\n    return { status }\n  }\n\n  async handle(\n    { project },\n    { gitlab_url: baseUrl = 'https://gitlab.com', branch = 'main' },\n  ) {\n    const data = await this.fetch({\n      project,\n      branch,\n      baseUrl,\n    })\n    const { status } = this.constructor.transform(data)\n    return this.constructor.render({ status })\n  }\n}\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/gitlab/gitlab-pipeline-status.service.js#L72-L108","documentation":"The GitLab pipeline status service throws this NotFound error when the GitLab API response carries a message/status of 'unknown', meaning no pipeline exists for the requested ref. The library renders a 'branch not found' badge rather than an empty status.","triggerScenarios":"Requesting a pipeline status badge for a branch name that does not exist in the GitLab repository (typo, renamed/deleted branch), or a ref that has never had a pipeline run.","commonSituations":"Default branch renamed from master to main while the badge still points at the old name; feature branch merged and deleted leaving a stale README badge; project uses merge request pipelines only so branch ref has no pipeline.","solutions":["Fix the branch/ref name in the badge URL to match an existing branch","Run a pipeline on the target branch (push a commit or trigger manually)","Point the badge at the default branch or use the project-level pipeline status","Update or remove stale README badges for deleted branches"],"exampleFix":"// before\n[![build](https://img.shields.io/gitlab/pipeline/user/repo/master)]\n// after (repo default branch is now main)\n[![build](https://img.shields.io/gitlab/pipeline/user/repo/main)]","handlingStrategy":"validation","validationCode":"const project = encodeURIComponent(repo)\nconst branches = await (await fetch(`https://gitlab.com/api/v4/projects/${project}/repository/branches`)).json()\nif (!branches.some(b => b.name === branch)) console.warn(`Branch ${branch} does not exist`)","typeGuard":"const hasPipeline = (d) => d != null && d.message !== 'unknown' && typeof d.status === 'string'","tryCatchPattern":"try {\n  const { status } = GitlabPipelineStatus.transform(data)\n} catch (e) {\n  if (e.prettyMessage === 'branch not found') {\n    // fall back to default branch badge\n  } else throw e\n}","preventionTips":["Update badge URLs whenever the default branch is renamed","Sweep READMEs for badges referencing deleted feature branches","Prefer the default-branch badge or a ref-agnostic URL"],"tags":["gitlab","ci","pipeline","branch","not-found"],"backgroundTag":"branch-not-found","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}