Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update error message for sfdx auth url #1136

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions messages/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Errors encountered:

Error authenticating with the refresh token due to: %s

# invalidSfdxAuthUrlError

Invalid SFDX authorization URL. Must be in the format "force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>". Note that the "instanceUrl" inside the SFDX authorization URL doesn\'t include the protocol ("https://"). Run "org display --target-org" on an org to see an example of an SFDX authorization URL.

# orgDataNotAvailableError

An attempt to refresh the authentication token failed with a 'Data Not Found Error'. The org identified by username %s does not appear to exist. Likely cause is that the org was deleted by another user or has expired.
Expand Down
10 changes: 4 additions & 6 deletions src/org/authInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,7 @@ export class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
);

if (!match) {
throw new SfError(
'Invalid SFDX auth URL. Must be in the format "force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>". Note that the SFDX auth URL uses the "force" protocol, and not "http" or "https". Also note that the "instanceUrl" inside the SFDX auth URL doesn\'t include the protocol ("https://").',
'INVALID_SFDX_AUTH_URL'
);
throw new SfError(messages.getMessage('invalidSfdxAuthUrlError'), 'INVALID_SFDX_AUTH_URL');
}
const [, clientId, clientSecret, refreshToken, loginUrl] = match;
return {
Expand Down Expand Up @@ -1073,8 +1070,9 @@ export class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
let authFieldsBuilder: TokenResponse;
try {
authFieldsBuilder = await oauth2.refreshToken(ensure(fullOptions.refreshToken));
} catch (err) {
throw messages.createError('refreshTokenAuthError', [(err as Error).message]);
} catch (err: unknown) {
const cause = err instanceof Error ? err : SfError.wrap(err);
throw messages.createError('refreshTokenAuthError', [cause.message], undefined, cause);
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
Loading