Skip to content

Commit

Permalink
Throw the API exception with authorization URL on SCMunauthorised err…
Browse files Browse the repository at this point in the history
…or (#621)

Fixes a bug with broken oauth flow caused by #615
  • Loading branch information
vinokurig committed Dec 5, 2023
1 parent c47c7f6 commit 7f83f5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.inject.Singleton;
import org.eclipse.che.api.core.ApiException;
import org.eclipse.che.api.core.BadRequestException;
import org.eclipse.che.api.factory.server.scm.exception.ScmUnauthorizedException;
import org.eclipse.che.api.factory.server.urlfactory.RemoteFactoryUrl.DevfileLocation;
import org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto;
import org.eclipse.che.api.factory.shared.dto.FactoryDto;
Expand Down Expand Up @@ -131,7 +132,9 @@ public Optional<FactoryMetaDto> createFactoryFromDevfile(
continue;
} catch (DevfileException e) {
LOG.debug("Unexpected devfile exception: {}", e.getMessage());
throw new ApiException(e.getMessage());
throw e.getCause() instanceof ScmUnauthorizedException
? toApiException(e, location)
: new ApiException(e.getMessage());
}
if (isNullOrEmpty(devfileYamlContent)) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public String location() {
} catch (ApiException e) {
assertTrue(e.getClass().isAssignableFrom(expectedClass));
assertEquals(e.getMessage(), expectedMessage);
if (e.getServiceError() instanceof ExtendedError)
if ("SCM Authentication required".equals(e.getMessage()))
assertEquals(((ExtendedError) e.getServiceError()).getAttributes(), expectedAttributes);
}
}
Expand Down

0 comments on commit 7f83f5f

Please sign in to comment.