Skip to content

Commit

Permalink
Return early on invalid_client OAuth exception. (actions#2721)
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang authored and ashb committed Jul 28, 2023
1 parent 2a7e9ad commit b7182d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Runner.Listener/MessageListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,15 @@ public async Task<Boolean> CreateSessionAsync(CancellationToken token)
Trace.Error("Catch exception during create session.");
Trace.Error(ex);

if (ex is VssOAuthTokenRequestException && creds.Federated is VssOAuthCredential vssOAuthCred)
if (ex is VssOAuthTokenRequestException vssOAuthEx && creds.Federated is VssOAuthCredential vssOAuthCred)
{
// "invalid_client" means the runner registration has been deleted from the server.
if (string.Equals(vssOAuthEx.Error, "invalid_client", StringComparison.OrdinalIgnoreCase))
{
_term.WriteError("Failed to create a session. The runner registration has been deleted from the server, please re-configure.");
return false;
}

// Check whether we get 401 because the runner registration already removed by the service.
// If the runner registration get deleted, we can't exchange oauth token.
Trace.Error("Test oauth app registration.");
Expand Down

0 comments on commit b7182d4

Please sign in to comment.