{"record":{"id":"ecc1cae01d014d4e","repo":"gastownhall/beads","slug":"create-remote-origin-w","errorCode":null,"errorMessage":"create remote origin: %w","messagePattern":"create remote origin: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_proxied_server.go","lineNumber":403,"sourceCode":"\t\treturn \"bd init\", nil\n\t})\n}\n\n// configureProxiedInitDoltRemote adds the sync remote, skipping a name that is\n// already taken.\nfunc configureProxiedInitDoltRemote(ctx context.Context, provider uow.UnitOfWorkProvider, remoteURL string) error {\n\treturn uow.RunTx(ctx, provider, func(ctx context.Context, uw uow.UnitOfWork) (string, error) {\n\t\tremotes, err := uw.DoltRemoteUseCase().ListRemotes(ctx)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"list remotes: %w\", err)\n\t\t}\n\t\tfor _, r := range remotes {\n\t\t\tif r.Name == \"origin\" {\n\t\t\t\treturn \"\", nil\n\t\t\t}\n\t\t}\n\t\tif err := uw.DoltRemoteUseCase().CreateRemote(ctx, \"origin\", remoteURL); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"create remote origin: %w\", err)\n\t\t}\n\t\treturn \"\", nil\n\t})\n}\n\n// adoptTeamServerIdentity reads the bts-provisioned identity out of the shared\n// database, following the gateway contract: adopt if present, hard error if\n// absent — bd never writes identity in team-server mode.\n//\n// ABSENT means \"unprovisioned, tell them to run bts init\" and UNREADABLE means\n// \"the connection failed, say so\"; keeping those apart is the InitVerifier\n// role's promise. The two markers arrive as ONE snapshot, so the prefix and the\n// project id cannot come from either side of a concurrent write.\nfunc adoptTeamServerIdentity(ctx context.Context, verifier issueops.InitVerifier, dbName, localPrefix string, prefixIsExplicit bool, localProjectID string) (prefix, projectID string, err error) {\n\tidentity, readErr := verifier.VerifyIdentity(ctx, issueops.VerifyIdentityRequest{})\n\tif _, err := resolveInitIssuePrefix(true, identity.Prefix, dbName, localPrefix, readErr); err != nil {\n\t\tif readErr == nil {\n\t\t\treturn \"\", \"\", fmt.Errorf(","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_proxied_server.go#L385-L421","documentation":"After confirming no remote named 'origin' exists, bd creates it pointing at remoteURL. This wrapper fires when DoltRemoteUseCase().CreateRemote(ctx, \"origin\", remoteURL) fails during proxied-server init. Note origin is created unconditionally here (existence already checked), so the cause is usually storage, connectivity, or an invalid remote URL.","triggerScenarios":"bd init in team-server mode where creating the 'origin' remote fails — bad remote URL, remote table write failure, server connection drop between ListRemotes and CreateRemote, or a race where another init created origin concurrently.","commonSituations":"Malformed remoteURL passed to init; concurrent bd init runs both passing the existence check; permissions lacking on the remotes table.","solutions":["Validate the remote URL supplied to bd init is a well-formed Dolt/Git remote","Re-run bd init — the existence check makes it idempotent if origin now exists","Serialize concurrent init runs; the second run will skip creation","Check the wrapped driver error for table/permission issues"],"exampleFix":"// before\nerr: \"create remote origin: invalid remote url\"\n// after\nbd init --remote https://doltremoteapi.dolthub.com/org/correct-repo","handlingStrategy":"validation","validationCode":"u, err := url.Parse(remoteURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"remote URL %q must be an absolute https/ssh URL\", remoteURL)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"create remote origin:\") {\n    // idempotent path: re-running init skips creation if origin now exists\n    log.Printf(\"remote creation failed: %v\", errors.Unwrap(err))\n}","preventionTips":["Pass a well-formed absolute Dolt remote URL to init","Avoid concurrent bd init runs against the same database — origin creation races","Re-run init safely: existing 'origin' is detected and skipped","Verify write permissions on the remotes table"],"tags":["init","dolt","remote","team-server","git-remote"],"backgroundTag":"dolt-remote-create-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}