[Bug] restic cat config on Azure Storage Account with a missing Container takes 15 mins to fail
Output of restic version
restic 0.19.1 compiled with go1.26.4 on darwin/arm64
What backend/service did you use to store the repository?
Azure Blob Storage, authenticated with AZURE_ACCOUNT_NAME and AZURE_ACCOUNT_KEY.
Problem description / Steps to reproduce
Any command that opens an existing repository blocks for 15 minutes when the Azure container does not exist, then fails. restic init against the same location creates the container right away.
Pick a storage account and a container name that does not exist in it.
Run a command that opens the repository:
export AZURE_ACCOUNT_NAME=<account> export AZURE_ACCOUNT_KEY=<key> export RESTIC_PASSWORD=<password> restic -r azure:does-not-exist:/repo cat configrestic retries for 15 minutes before it exits.
For comparison, a missing config blob in a container that does exist fails at once with repository does not exist.
Expected behavior
A missing container fails immediately, the same as a missing config file:
Fatal: repository does not exist: unable to open config file: ...
Is there a repository at the following location?Actual behavior
restic retries the Stat of the config file until the 15-minute retry limit runs out:
Stat(<config/>) returned error, retrying after 1.106390407s: blob.GetProperties: HEAD https://<account>.blob.core.windows.net/does-not-exist/repo%2Fconfig
--------------------------------------------------------------------------------
RESPONSE 404: 404 The specified container does not exist.
ERROR CODE: ContainerNotFound
--------------------------------------------------------------------------------
Response contained no body
--------------------------------------------------------------------------------
Stat(<config/>) returned error, retrying after 1.377195697s: blob.GetProperties: HEAD https://<account>.blob.core.windows.net/does-not-exist/repo%2Fconfig
--------------------------------------------------------------------------------
RESPONSE 404: 404 The specified container does not exist.
ERROR CODE: ContainerNotFound
--------------------------------------------------------------------------------
Response contained no body
--------------------------------------------------------------------------------
...
repeated for 15mins
...
Fatal: unable to open config file: blob.GetProperties: HEAD https://<account>.blob.core.windows.net/does-not-exist/repo%2Fconfig
--------------------------------------------------------------------------------
RESPONSE 404: 404 The specified container does not exist.
ERROR CODE: ContainerNotFound
--------------------------------------------------------------------------------
Response contained no body
--------------------------------------------------------------------------------
azure:does-not-exist:/repoThen it exits with the generic error instead of ErrNoRepository:
Fatal: unable to open config file: ... ContainerNotFoundDo you have any idea what may have caused this?
The Azure backend classifies ContainerNotFound as neither "not exist" nor permanent, so the retry backend keeps retrying it.
hasRepositoryConfigcallsStaton the config file through the retry-wrapped backend (global.go#L341-L349). The wrapper is set up with a 15-minute limit (global.go#L615).- The retry
Statstops early only whenIsNotExistis true (backend_retry.go#L231-L251). - Azure
IsNotExistonly matchesBlobNotFound(azure.go#L204-L206), andIsPermanentErroronly adds 401, 403 and 416 (azure.go#L208-L220). A 404ContainerNotFoundmatches neither.
My preferred fix would be to make IsNotExist also match bloberror.ContainerNotFound: A missing container means every object in it is missing, and hasRepositoryConfig then returns ErrNoRepository.
Another possibility is to add it to IsPermanentError, which stops the retries; but it keeps the generic error as the cause, and I'm pretty sure 404 was omitted from this for a reason.
Source: restic/restic