Skip to content

Fix unreachable dolt-login hint on PermissionDenied push errors#11274

Open
kevglynn wants to merge 1 commit into
dolthub:mainfrom
kevglynn:fix/push-permission-hint-783
Open

Fix unreachable dolt-login hint on PermissionDenied push errors#11274
kevglynn wants to merge 1 commit into
dolthub:mainfrom
kevglynn:fix/push-permission-hint-783

Conversation

@kevglynn

@kevglynn kevglynn commented Jul 8, 2026

Copy link
Copy Markdown

Summary

  • The hint text in handlePushError ("have you logged into DoltHub using 'dolt login'?") has been unreachable since PushToRemoteBranch started wrapping ErrUnknownPushErr — the sentinel comparison used switch/== on a wrapped error, and the gRPC status was stringified so status.FromError couldn't see codes.PermissionDenied
  • Also fixes the RpcError type assertion in the same function, which suffered the same wrapping issue (the FullDetails() code path was similarly dead)

Changes

  • go/libraries/doltcore/env/actions/remotes.go: Changed fmt.Errorf("%w; %s", ErrUnknownPushErr, err.Error()) to fmt.Errorf("%w: %w", ErrUnknownPushErr, err) — preserves both the sentinel and the original error (including RpcError with its captured gRPC status) in the chain
  • go/cmd/dolt/commands/push.go: Replaced switch err / err.(*RpcError) with errors.Is / errors.As; extracted isPermissionDeniedErr helper that checks the RpcError status via errors.As, falling back to error text matching
  • go/cmd/dolt/commands/push_test.go: 6 test cases for isPermissionDeniedErr covering wrapped RpcError with PermissionDenied, Internal, and Unauthenticated codes; plain text matching; non-matching errors; nil

Test plan

  • go test -run TestIsPermissionDeniedErr ./cmd/dolt/commands/ -v — all 6 cases pass
  • go test ./cmd/dolt/commands/ — full package passes
  • go test ./libraries/doltcore/env/actions/ — passes (error format change)
  • go test ./libraries/doltcore/remotestorage/ — passes
  • go vet ./cmd/dolt/commands/ — clean
  • CI

Closes #783

Made with Cursor

The hint text in handlePushError ("have you logged into DoltHub using
'dolt login'?") was unreachable due to two bugs:

1. The sentinel ErrUnknownPushErr was compared with switch/== but
   PushToRemoteBranch wraps it via fmt.Errorf("%w; %s", ...), so the
   equality check never matched. Fixed: use errors.Is.

2. The gRPC status was stringified (%s) in the same wrap, so
   status.FromError could never extract codes.PermissionDenied. Fixed:
   use %w to preserve the original error in the chain, and extract the
   status from RpcError via errors.As.

Also fixes the RpcError type assertion (err.(*RpcError)) which suffered
the same wrapping issue — now uses errors.As.

Closes dolthub#783

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompt user to run "dolt login" on PermissionDenied error on "dolt push"

2 participants