Skip to content

Commit 4dac7b2

Browse files
julianknutsenclaude
andcommitted
Fix DoltHub fork auth and surface join errors to stderr
Add authorization header for DoltHub GraphQL API (was only sending cookie). Print join errors to stderr so they're visible with cobra's SilenceErrors enabled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b8efb20 commit 4dac7b2

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

cmd/wl/cmd_join.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ func runJoin(stdout, stderr io.Writer, upstream, handle, displayName, email, for
150150
fmt.Fprintf(stdout, "Joining wasteland %s (fork to %s/%s)...\n", upstream, forkOrg, dbName)
151151
cfg, err := svc.Join(upstream, forkOrg, handle, displayName, email, wlVersion)
152152
if err != nil {
153-
return err
153+
fmt.Fprintf(stderr, "wl join: %v\n", err)
154+
return errExit
154155
}
155156

156157
fmt.Fprintf(stdout, "\n%s Joined wasteland: %s\n", style.Bold.Render("✓"), upstream)

internal/remote/dolthub.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func (d *DoltHubProvider) Fork(fromOrg, fromDB, toOrg string) error {
6868
return fmt.Errorf("creating fork request: %w", err)
6969
}
7070
req.Header.Set("Content-Type", "application/json")
71+
req.Header.Set("authorization", "token "+d.token)
7172
req.Header.Set("Cookie", "dolthubToken="+d.token)
7273

7374
client := &http.Client{Timeout: 60 * time.Second}

internal/remote/dolthub_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ func TestDoltHubProvider_Fork(t *testing.T) {
2727
t.Errorf("expected POST, got %s", r.Method)
2828
}
2929

30-
// Verify cookie auth.
31-
cookie := r.Header.Get("Cookie")
32-
if !strings.Contains(cookie, "dolthubToken=test-token") {
33-
t.Errorf("expected dolthubToken cookie, got %q", cookie)
30+
// Verify auth header.
31+
if r.Header.Get("authorization") != "token test-token" {
32+
t.Errorf("expected auth header, got %q", r.Header.Get("authorization"))
3433
}
3534

3635
// Verify GraphQL request body.

0 commit comments

Comments
 (0)