dagger/dagger · error
remote workspace %q: parsing git ref: %w
Error message
remote workspace %q: parsing git ref: %w
What it means
loadWorkspaceFromRemote wraps any error from parseWorkspaceRemoteRef with this prefix, indicating the remote workspace ref could not be parsed as a git URL/ref (bad URL scheme, invalid fragment, or invalid subdir).
Source
Thrown at engine/server/session_workspaces.go:363
if subdir == "" {
return ".", nil
}
subdir = filepath.Clean(subdir)
subdir = strings.TrimPrefix(subdir, string(filepath.Separator))
if subdir == "" || subdir == "." {
return ".", nil
}
if !filepath.IsLocal(subdir) {
return "", fmt.Errorf("path points outside repository: %q", subdir)
}
return subdir, nil
}
// loadWorkspaceFromRemote clones a git repo and detects/loads the workspace from it.
func (srv *Server) loadWorkspaceFromRemote(ctx context.Context, client *daggerClient, remoteRef string) error {
parsedRef, err := parseWorkspaceRemoteRef(ctx, remoteRef)
if err != nil {
return fmt.Errorf("remote workspace %q: parsing git ref: %w", remoteRef, err)
}
tree, gitRef, err := srv.cloneGitTree(ctx, client.dag, parsedRef.cloneRef, parsedRef.version)
if err != nil {
return fmt.Errorf("remote workspace %q: %w", remoteRef, err)
}
resolveLocalRef := func(ws *workspace.Workspace, relPath string) string {
subPath := filepath.Join(ws.Root, relPath)
return core.GitRefString(parsedRef.cloneRef, subPath, parsedRef.version)
}
return srv.detectAndLoadWorkspaceWithRootfs(ctx, client,
&core.DirectoryStatFS{Dir: tree},
func(ctx context.Context, path string) ([]byte, error) {
return core.DirectoryReadFile(ctx, tree, path)
},
parsedRef.workspaceSubdir,View on GitHub (pinned to 82ba2681db)
Solutions
- Validate the ref is a full git URL (git ls-remote or url.Parse) before declaring it
- Fix the #fragment syntax: #<ref> and #<ref>:<subdir> as supported by the parser
- Check the wrapped cause for the subdir normalization error and correct the subdir
- If the target is local, ensure the local dir exists so the remote branch isn't attempted
Example fix
// before // workspace: github.com/me/proj#main:/bad/../sub (unparseable) // after // workspace: https://github.com/me/proj.git#main:sub
Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(ref)
if err != nil || (u.Scheme == "" && !strings.HasPrefix(ref, "git@")) {
return fmt.Errorf("ref %q is not a parsable git URL", ref)
} Try / catch
if err := ensureWorkspaceLoaded(ctx, client, mode, ref); err != nil {
if strings.Contains(err.Error(), "parsing git ref") {
return fmt.Errorf("workspace ref %s is not a valid git ref; use https://host/repo.git[#ref[:subdir]]", ref)
}
return err
} Prevention
- Use fully qualified git URLs (https://host/repo.git) in workspace declarations
- Follow the documented fragment syntax for ref/subdir
- Test ref parsing locally (url.Parse + subdir sanitization) before deploying config
When it happens
Trigger: loadWorkspaceFromDeclaredRef falls back to the remote path and passes a ref that parseWorkspaceRemoteRef cannot parse — malformed git URL, unsupported scheme, or invalid #fragment subdir.
Common situations: Ref missing a valid git remote part; fragment subdir violating normalizeWorkspaceRemoteSubdir rules; user passing a plain directory name that isn't a git URL at all.
Related errors
- parse hunk header %q: %w
- invalid signature %q
- invalid signature date %q
- parse timestamp: %w
- failed to parse rev-list output: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/97bf628a340fc9d4.
Report an issue: GitHub.