{"record":{"id":"b5c3ee6c35741bb2","repo":"gastownhall/beads","slug":"dolt-clone-s-w","errorCode":null,"errorMessage":"dolt clone %s: %w","messagePattern":"dolt clone (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/versioncontrolops/clone.go","lineNumber":26,"sourceCode":"\n// DoltClone clones a Dolt database from a remote URL.\n// conn must be a non-transactional database connection.\n// The database parameter specifies the local database name for the clone.\n// If user is non-empty, authenticates with that user. Dolt reads the remote\n// password from DOLT_REMOTE_PASSWORD.\nfunc DoltClone(ctx context.Context, conn DBConn, remoteURL, database, user string) error {\n\tquery := \"CALL DOLT_CLONE(?, ?)\"\n\targs := []any{remoteURL, database}\n\tif user != \"\" {\n\t\tquery = \"CALL DOLT_CLONE('--user', ?, ?, ?)\"\n\t\targs = []any{user, remoteURL, database}\n\t}\n\n\t// GH#4272: the initial fetch runs git hooks just like push/pull; disable\n\t// them for the clone window too (see remotes.go for the full rationale).\n\treturn withRemoteEnvGuards(func() error {\n\t\tif _, err := conn.ExecContext(ctx, query, args...); err != nil {\n\t\t\treturn fmt.Errorf(\"dolt clone %s: %w\", sanitizeURL(remoteURL), err)\n\t\t}\n\t\treturn nil\n\t})\n}\n\n// sanitizeURL removes credentials from a URL for safe error reporting.\nfunc sanitizeURL(raw string) string {\n\tparsed, err := url.Parse(raw)\n\tif err != nil {\n\t\treturn raw\n\t}\n\tparsed.User = nil\n\tparsed.RawQuery = \"\"\n\tparsed.Fragment = \"\"\n\treturn parsed.String()\n}\n","sourceCodeStart":8,"sourceCodeEnd":43,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/versioncontrolops/clone.go#L8-L43","documentation":"DoltClone executes CALL DOLT_CLONE(?, ?) to clone a remote Dolt database and wraps failures as 'dolt clone <url>: %w'. The URL is passed through sanitizeURL so credentials (userinfo, query, fragment) are stripped before the error is reported. Failures cover unreachable remotes, bad URLs, authentication failures, or a non-empty target database.","triggerScenarios":"Calling DoltClone with an unreachable or misspelled remote URL; missing/incorrect DOLT_REMOTE_PASSWORD or --user credentials; the target local database name already exists; network/firewall blocking the remote; git hooks or env guards interfering during the clone window.","commonSituations":"CI environments where DOLT_REMOTE_PASSWORD isn't set; cloning over HTTPS from a private remote with expired credentials; firewall/proxy blocking the remote port; re-cloning into an existing database directory.","solutions":["Verify the remote URL is reachable (dolt clone / curl the host) and correctly formed","Set DOLT_REMOTE_PASSWORD (and user) in the environment before cloning; for embedded auth use the --user path","Ensure the target local database name does not already exist","Check the sanitized URL in the error and the wrapped driver error for auth-vs-network distinction"],"exampleFix":"// before\nerr := versioncontrolops.DoltClone(ctx, conn, remoteURL, \"cloned\", \"\")\n// after\nos.Setenv(\"DOLT_REMOTE_PASSWORD\", token) // or pass user and use credentials store\nerr := versioncontrolops.DoltClone(ctx, conn, remoteURL, \"cloned\", \"myuser\")","handlingStrategy":"validation","validationCode":"u, err := url.Parse(remoteURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid remote URL: %q\", remoteURL)\n}\nif os.Getenv(\"DOLT_REMOTE_PASSWORD\") == \"\" && needsAuth(u) {\n    return fmt.Errorf(\"DOLT_REMOTE_PASSWORD not set\")\n}","typeGuard":null,"tryCatchPattern":"err := versioncontrolops.DoltClone(ctx, conn, remoteURL, dbName, user)\nif err != nil {\n    // err message contains sanitized URL; check cause for auth vs network\n    log.Printf(\"clone of %s failed: %v\", remoteURL, err)\n    return fmt.Errorf(\"clone failed (check URL, credentials, and target name): %w\", err)\n}","preventionTips":["Set DOLT_REMOTE_PASSWORD (and --user) before cloning private remotes","Sanity-check the remote URL and network reachability first","Ensure the target local database name is unused","Strip credentials from URLs before logging (the library already does this)"],"tags":["dolt","clone","remote","network","authentication"],"backgroundTag":"dolt-remote-operation-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}