{"record":{"id":"cf3a8a47e40782b0","repo":"dagger/dagger","slug":"errgitnorepo","errorCode":"ErrGitNoRepo","errorMessage":"not a git repository","messagePattern":"not a git repository","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"util/gitutil/error.go","lineNumber":11,"sourceCode":"package gitutil\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"strings\"\n)\n\nvar (\n\tErrGitAuthFailed       = errors.New(\"git authentication failed\")\n\tErrGitNoRepo           = errors.New(\"not a git repository\")\n\tErrShallowNotSupported = errors.New(\"shallow clone not supported\")\n\t// ErrSHAFetchUnsupported is a normalized signal that retry-by-named-ref may succeed.\n\tErrSHAFetchUnsupported = errors.New(\"sha fetch unsupported by remote\")\n)\n\nfunc translateError(err error, stderr string) error {\n\tif err == nil {\n\t\treturn nil\n\t}\n\n\tif errors.Is(err, context.DeadlineExceeded) {\n\t\treturn context.DeadlineExceeded\n\t}\n\tif errors.Is(err, context.Canceled) {\n\t\treturn context.Canceled\n\t}\n\n\tstderr = strings.ToLower(stderr)","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/util/gitutil/error.go#L1-L29","documentation":"Sentinel error returned by translateError when git reports the target path is not a git repository. Wrappers like MaterializeHostGitCheckout, GitCheckoutState, PackGitCheckout propagate it so callers can treat 'no git context' as an expected, non-fatal condition.","triggerScenarios":"Running git commands (rev-parse, status, packing) in a directory without a .git dir; GitCheckoutState on a plain host directory; engine client maps git.NOT_A_REPO result errors onto this sentinel.","commonSituations":"Running dagger in a plain folder instead of a git checkout; submodules or vendored dirs outside the repo; user expects git-based provenance but the context isn't a repo.","solutions":["Initialize git in the directory (git init) or run the command from inside the actual repository","Treat errors.Is(err, gitutil.ErrGitNoRepo) as 'no git context' and proceed without provenance (as core/git_hostdir.go returns ErrNoGitContext)","Check you are in the intended repo root rather than a subdirectory or copied tree","Copy the .git directory or use a proper checkout when materializing host directories"],"exampleFix":"// before\nstate, err := bk.GitCheckoutState(ctx, hostPath)\nif err != nil {\n\treturn err\n}\n// after\nstate, err := bk.GitCheckoutState(ctx, hostPath)\nif err != nil {\n\tif errors.Is(err, gitutil.ErrGitNoRepo) {\n\t\treturn tree, ErrNoGitContext\n\t}\n\treturn err\n}","handlingStrategy":"type-guard","validationCode":"if _, err := os.Stat(filepath.Join(dir, \".git\")); err != nil {\n\t// not a git repo — skip git-based provenance\n}","typeGuard":"func isNoRepo(err error) bool {\n\treturn errors.Is(err, gitutil.ErrGitNoRepo)\n}","tryCatchPattern":"state, err := bk.GitCheckoutState(ctx, hostPath)\nif err != nil {\n\tif errors.Is(err, gitutil.ErrGitNoRepo) {\n\t\treturn tree, ErrNoGitContext\n\t}\n\treturn err\n}","preventionTips":["Run git-dependent features only inside real checkouts","git init or clone before invoking git-based tooling","Map the sentinel to a graceful 'no provenance' path"],"tags":["go","git","repository","provenance"],"backgroundTag":"not-a-git-repository","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}