{"record":{"id":"4f2a4104988372cf","repo":"docker/compose","slug":"repository-does-not-contain-ref-s-output-q-w","errorCode":null,"errorMessage":"repository does not contain ref %s, output: %q: %w","messagePattern":"repository does not contain ref (.+?), output: %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/git.go","lineNumber":179,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid git subdirectory path: %w\", err)\n\t}\n\n\tif relPath == \"..\" || strings.HasPrefix(relPath, \"../\") || strings.HasPrefix(relPath, \"..\\\\\") {\n\t\treturn fmt.Errorf(\"git subdirectory escapes base directory: %s\", subDir)\n\t}\n\n\treturn nil\n}\n\nfunc (g gitRemoteLoader) resolveGitRef(ctx context.Context, path string, ref *gitutil.GitRef) error {\n\tif !commitSHA.MatchString(ref.Ref) {\n\t\tcmd := exec.CommandContext(ctx, \"git\", \"ls-remote\", \"--exit-code\", ref.Remote, ref.Ref)\n\t\tcmd.Env = g.gitCommandEnv()\n\t\tout, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tif cmd.ProcessState.ExitCode() == 2 {\n\t\t\t\treturn fmt.Errorf(\"repository does not contain ref %s, output: %q: %w\", path, string(out), err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to access repository at %s:\\n %s\", ref.Remote, out)\n\t\t}\n\t\tif len(out) < 40 {\n\t\t\treturn fmt.Errorf(\"unexpected git command output: %q\", string(out))\n\t\t}\n\t\tsha := string(out[:40])\n\t\tif !commitSHA.MatchString(sha) {\n\t\t\treturn fmt.Errorf(\"invalid commit sha %q\", sha)\n\t\t}\n\t\tref.Ref = sha\n\t}\n\treturn nil\n}\n\nfunc (g gitRemoteLoader) checkout(ctx context.Context, path string, ref *gitutil.GitRef) error {\n\terr := os.MkdirAll(path, 0o700)\n\tif err != nil {","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/pkg/remote/git.go#L161-L197","documentation":"While resolving a non-SHA git ref for a remote include, Compose runs `git ls-remote --exit-code <remote> <ref>`. Exit code 2 specifically means the repository is reachable but does not contain the requested ref (branch/tag). The full path and git output are included for context.","triggerScenarios":"Including `git://host/repo.git#feature-branch` where that branch doesn't exist (renamed, deleted, typo), or a tag that was never pushed. The error names the original include path, not just the ref.","commonSituations":"Branch renamed/merged and deleted upstream; typo'd tag in config; refs existing only in forks; shallow server-side ref filtering (some hosts hide refs behind permissions, in which case git may also report exit 2).","solutions":["Check available refs: `git ls-remote <remote>` and copy the exact branch/tag name","Pin to a full 40-char commit SHA, which skips ls-remote resolution entirely","If the repo is private, verify credentials — hidden refs can look like missing refs"],"exampleFix":"# before\ninclude:\n  - path: git://github.com/org/repo.git#feat-new-ui\n\n# after (branch was renamed)\ninclude:\n  - path: git://github.com/org/repo.git#feat/ui","handlingStrategy":"validation","validationCode":"# verify the ref exists before running compose (fast preflight)\nremote='https://github.com/org/repo.git'; ref='feature-branch'\ngit ls-remote --exit-code \"$remote\" \"$ref\" >/dev/null || { echo \"ref $ref missing in $remote\" >&2; exit 1; }\ndocker compose -f compose.yaml config","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin production includes to full 40-char commit SHAs — resolution is skipped and refs can't dangle","Add a CI step that ls-remotes every branch/tag referenced by git:// includes"],"tags":["compose","git-remote","ref-not-found","include"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}