Skip to content

migrate-repo command retries 5 times if target repository exists #1447

@akordowski

Description

@akordowski

Description

When calling the migrate-repo command it is checked if the target repository already exists. If the repository is found then the check method retries the call 5 time before throwing a exception. This is the call stack:

public virtual async Task<bool> DoesRepoExist(string org, string repo)
{
var url = $"{_apiUrl}/repos/{org.EscapeDataString()}/{repo.EscapeDataString()}";
try
{
await _client.GetNonSuccessAsync(url, HttpStatusCode.NotFound);
return false;
}
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.OK)
{
return true;
}
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.MovedPermanently)
{
return false;
}
}

public virtual async Task<string> GetNonSuccessAsync(string url, HttpStatusCode status) => (await GetWithRetry(url, expectedStatus: status)).Content;

The GetNonSuccessAsync() function calls a GetWithRetry() by passing an expected HttpStatusCode.

IMO the GetNonSuccessAsync() function should call a sub-function without retry and should fail if the expected HttpStatusCode is returned, or is this behavior intentional?

Reproduction Steps

Run a migration against an existing repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions