{"record":{"id":"003d0d4c2c1edfa5","repo":"badges/shields","slug":"go-version-missing-in-go-mod-003d0d","errorCode":null,"errorMessage":"Go version missing in go.mod","messagePattern":"Go version missing in go\\.mod","errorType":"exception","errorClass":"InvalidResponse","httpStatus":424,"severity":"error","filePath":"services/gitlab/gitlab-go-mod.service.js","lineNumber":113,"sourceCode":"    const url = `${gitlabUrl}/api/v4/projects/${encodeURIComponent(\n      project,\n    )}/repository/files/${encodeURIComponent(filename)}/raw`\n    const options = { searchParams: { ref: branch || 'HEAD' } }\n    const httpErrors = httpErrorsFor('project or file not found')\n    const { buffer } = await this._request(\n      this.authHelper.withBearerAuthHeader({\n        url,\n        options,\n        httpErrors,\n      }),\n    )\n    return buffer\n  }\n\n  static transform(content) {\n    const match = goVersionRegExp.exec(content)\n    if (!match) {\n      throw new InvalidResponse({\n        prettyMessage: 'Go version missing in go.mod',\n      })\n    }\n\n    return {\n      go: match[1],\n    }\n  }\n\n  async handle(\n    { user, repo, branch },\n    { filename = 'go.mod', gitlabUrl = 'https://gitlab.com' },\n  ) {\n    const content = await this.fetch({\n      user,\n      repo,\n      branch,\n      filename,","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/gitlab/gitlab-go-mod.service.js#L95-L131","documentation":"The GitLab go-mod service parses the repository's go.mod file and extracts the `go` directive via `goVersionRegExp`. If the regex matches nothing, `transform` throws `InvalidResponse` with 'Go version missing in go.mod'. The file was fetched, but it contains no usable Go version directive.","triggerScenarios":"go.mod exists but lacks a `go X.Y` directive (old modules created before Go 1.12 convention, or hand-stripped files); the fetched content is not actually a go.mod (wrong path/ref, or GitLab returned an error page).","commonSituations":"Legacy module predating the go directive; someone edited go.mod and removed the directive; badge URL points at a branch/ref where go.mod differs; GitLab raw endpoint returning non-go.mod content due to wrong file path.","solutions":["Add a `go 1.x` directive to go.mod and commit it","Verify the badge URL's ref/branch points at a go.mod containing the directive","Confirm the file path the service fetches is the real go.mod at repo root"],"exampleFix":"// before (go.mod)\nmodule example.com/m\n// after\nmodule example.com/m\n\ngo 1.21","handlingStrategy":"validation","validationCode":"const content = await fetch(rawGoModUrl).then(r => r.text())\nif (!/^go\\s+\\d+\\.\\d+/m.test(content)) {\n  throw new Error('go.mod lacks a go directive; run: go mod edit -go=1.21')\n}","typeGuard":"null","tryCatchPattern":"try {\n  await fetchGoModBadge(project)\n} catch (e) {\n  if (e.message === 'Go version missing in go.mod') return 'unknown'\n  throw e\n}","preventionTips":["Keep a `go 1.x` directive in go.mod (`go mod edit -go=1.21`)","Ensure the badge URL targets the branch/ref where go.mod has the directive","Verify the fetched file is actually go.mod at the module root"],"tags":["gitlab","go","parse-error","missing-field"],"backgroundTag":"expected-field-missing-in-file","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}