microsoft/ailab · error · ApplicationException

file does not exist in container

Error message

file {file} does not exist in container {container}

What it means

GetFile validates its inputs before touching blob storage: it resolves the named container via CloudBlobClient.GetContainerReference and calls ExistsAsync; if the container (or the file blob within it, in the same guard block) is not present in the storage account, the method aborts with this error instead of returning null. It fires when a caller passes a container or file name that was deleted, never uploaded, or misspelled — the callers GetPredictionAsync, data, and content pass names derived from prediction results, so it typically means stale or absent prediction data.

Solutions

  1. Verify the container and file names against containers/files actually listed by GetPredictionsAsync before calling GetFile
  2. Check that the blob upload/prediction pipeline completed and the container still exists in the storage account
  3. If the file may legitimately be absent, catch the exception (or pre-check blobcontainer.ExistsAsync) and return null or an empty result instead of surfacing the error
  4. Correct any casing or typo in the container/file parameters, since blob names are case-sensitive
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at Sketch2Code/Sketch2Code.Core/Services/ObjectDetectionAppService.cs:297 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/ailab@89fe2fc620 (2026-09-13). Data as JSON: /api/errors/bb1125c2d1263aa2. Report an issue: GitHub.

Appendix: source

Thrown at Sketch2Code/Sketch2Code.Core/Services/ObjectDetectionAppService.cs:297

            return detail;
        }
        public async Task<IList<CloudBlobContainer>> GetPredictionsAsync()
        {
            return await Task.Run(() => _cloudBlobClient.ListContainers().Where(l => l.Name != "azure-webjobs-hosts")
                .OrderByDescending(c => c.Properties.LastModified).ToList());
        }
        public async Task<byte[]> GetFile(string container, string file)
        {
            var blobcontainer = _cloudBlobClient.GetContainerReference(container);
            if (!await blobcontainer.ExistsAsync())
            {
                throw new ApplicationException($"container {container} does not exist");
            }
            var blob = blobcontainer.GetBlobReference(file);
            if (!await blob.ExistsAsync())
            {
                throw new ApplicationException($"file {file} does not exist in container {container}");
            }
            using (var ms = new MemoryStream())
            {
                await blob.DownloadToStreamAsync(ms);
                return ms.ToArray();
            }
        }
        public async Task<T> GetFile<T>(string container, string file)
        {
            var data = await this.GetFile(container, file);
            if (data == null) return default(T);
            return JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(data));
        }
        public async Task<GroupBox> CreateGroupBoxAsync(IList<PredictedObject> predictedObjects)
        {
            var result = await Task.Run(() =>
            {
                //Project each prediction into its bounding box

View on GitHub (pinned to 89fe2fc620)