{"record":{"id":"d1f0459773be9720","repo":"OrchardCMS/OrchardCore","slug":"error-retrieving-file-info-for-path-ex-message","errorCode":null,"errorMessage":"Error retrieving file info for '${path}': ${ex.Message}","messagePattern":"Error retrieving file info for '(.+?)': (.+?)","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs","lineNumber":52,"sourceCode":"    public async Task<IFileStoreEntry> GetFileInfoAsync(string path)\n    {\n        try\n        {\n            var objectMetadata = await _amazonS3Client.GetObjectMetadataAsync(new GetObjectMetadataRequest\n            {\n                BucketName = _options.BucketName,\n                Key = this.Combine(_basePrefix, path),\n            });\n\n            return new AwsFile(path, objectMetadata.ContentLength, objectMetadata.LastModified);\n        }\n        catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)\n        {\n            return null;\n        }\n        catch (AmazonS3Exception ex)\n        {\n            throw new FileStoreException($\"Error retrieving file info for '{path}': {ex.Message}\", ex);\n        }\n    }\n\n    public async Task<IFileStoreEntry> GetDirectoryInfoAsync(string path)\n    {\n        if (string.IsNullOrEmpty(path))\n        {\n            return new AwsDirectory(path, _clock.UtcNow);\n        }\n\n        var awsDirectory = await _amazonS3Client.ListObjectsV2Async(new ListObjectsV2Request\n        {\n            BucketName = _options.BucketName,\n            Prefix = NormalizePrefix(this.Combine(_basePrefix, path)),\n            MaxKeys = 1,\n            FetchOwner = false,\n        });\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs#L34-L70","documentation":"AwsFileStorage.GetFileInfoAsync wraps unexpected AmazonS3Exception failures in FileStoreException. 404 responses are treated as 'file absent' (returns null), but any other S3 error — permissions, throttling, network, bad bucket — surfaces as this message with the path and the S3 error text as inner exception.","triggerScenarios":"Calling GetFileInfoAsync(path) when the S3 HEAD/Get-objects call fails with a non-404 AmazonS3Exception: invalid bucket name, missing IAM permissions, wrong region/credentials, or transient S3 throttling.","commonSituations":"Misconfigured AWS credentials/region in Media storage settings; IAM policy lacking s3:ListBucket/GetObject on the bucket prefix; bucket deleted or renamed while the module still points to it; S3 503 slowdown responses under load.","solutions":["Read the inner AmazonS3Exception (ErrorCode/StatusCode) to find the root cause: fix IAM policy, region, or bucket name","Validate Media > Amazon S3 settings (bucket, region, credentials) and run a connectivity test","Add retry with backoff for throttling (503/SlowDown) errors","Catch FileStoreException at call sites that must tolerate storage outages and degrade gracefully"],"exampleFix":"// before\nvar file = await fileStore.GetFileInfoAsync(path); // throws FileStoreException on S3 failure\n// after\ntry { var file = await fileStore.GetFileInfoAsync(path); }\ncatch (FileStoreException ex) { _logger.LogError(ex, \"S3 error for {Path}\", path); }","handlingStrategy":"try-catch","validationCode":"// pre-flight before calls:\nusing var resp = await _s3.GetBucketLocationAsync(new GetBucketLocationRequest { BucketName = bucket });\nif (resp.HttpStatusCode != HttpStatusCode.OK) throw new InvalidOperationException(\"Bucket unreachable\");","typeGuard":"bool IsFileAbsent(FileStoreException ex) => ex.InnerException is AmazonS3Exception s3 && s3.StatusCode == HttpStatusCode.NotFound;","tryCatchPattern":"try { info = await fileStore.GetFileInfoAsync(path); } catch (FileStoreException ex) when (ex.InnerException is AmazonS3Exception s3 && s3.StatusCode != HttpStatusCode.NotFound) { _logger.LogError(ex, \"S3 error for {Path}: {Code}\", path, s3.ErrorCode); }","preventionTips":["Validate bucket name, region and credentials at startup","Grant least-privilege IAM (GetObject/ListBucket) and test with the AWS CLI","Enable retry policy for throttling (503 SlowDown)","Check App_Data logs for the inner AmazonS3Exception ErrorCode"],"tags":["aws","s3","file-storage","network","io"],"backgroundTag":"file-read-failed","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}