git-ecosystem/git-credential-manager · error · ArgumentException

RemoteUri must be defined to generate Bitbucket DC OAuth2…

Error message

RemoteUri must be defined to generate Bitbucket DC OAuth2 endpoint Urls

What it means

BitbucketOAuth2Client.GetEndpoints builds the authorize/token endpoint URLs from settings.RemoteUri. If RemoteUri is null there is no server to point the OAuth2 flow at, so it throws ArgumentException before any network call is made.

Solutions

  1. Ensure git passes the full remote info: run the flow via `git fetch/push` against a proper Bitbucket DC remote URL.
  2. When invoking `git credential fill` manually, include protocol=, host= and path= lines in the input.
  3. Check the repository's origin URL is not empty/malformed (git remote -v) and fix it with git remote set-url.

Example fix

// before: incomplete input to the credential helper
$ echo "protocol=https" | git credential fill  # no host
// after:
$ printf "protocol=https\nhost=bitbucket.example.com\npath=/scm/proj/repo.git\n" | git credential fill
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(settings.RemoteUri)) throw new InvalidOperationException("Run via git with a valid remote URL");

Type guard

function hasRemoteUri(s) { return typeof s?.RemoteUri === 'string' && s.RemoteUri.length > 0; }

Try / catch

try { var endpoints = GetEndpoints(settings); } catch (ArgumentException ex) when (ex.Message.Contains("RemoteUri")) { /* re-run through git so host/path are supplied */ }

Prevention

When it happens

Trigger: Invoking BitbucketOAuth2Client (e.g. GetCredentialAsync) with an ISettings whose RemoteUri property is null — typically when the helper is invoked without a full remote URL in the query (no protocol=..., host=..., path=... parameters).

Common situations: Manually invoking git-credential fill with incomplete input; credential helpers wired up without remote URL info; custom tooling calling GCM's API with an empty or malformed remote URI.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/b805aec768a81adf. Report an issue: GitHub.

Appendix: source

Thrown at src/Atlassian.Bitbucket/DataCenter/BitbucketOAuth2Client.cs:74

        {
            // Check for developer override value
            if (settings.TryGetSetting(
                DataCenterConstants.EnvironmentVariables.OAuthClientSecret,
                Constants.GitConfiguration.Credential.SectionName, DataCenterConstants.GitConfiguration.Credential.OAuthClientSecret,
                out string clientSecret))
            {
                return clientSecret;
            }

            throw new ArgumentException("Bitbucket DC OAuth Client Secret must be defined");
        }

        private static OAuth2ServerEndpoints GetEndpoints(ISettings settings)
        {
            var remoteUri = settings.RemoteUri;
            if (remoteUri == null)
            {
                throw new ArgumentException("RemoteUri must be defined to generate Bitbucket DC OAuth2 endpoint Urls");
            }

            return new OAuth2ServerEndpoints(
                new Uri(BitbucketHelper.GetBaseUri(remoteUri) + "/rest/oauth2/latest/authorize"),
                new Uri(BitbucketHelper.GetBaseUri(remoteUri) + "/rest/oauth2/latest/token")
                );
        }
    }
}

View on GitHub (pinned to e8ce762cd0)