{"record":{"id":"0ca7489226316dca","repo":"OrchardCMS/OrchardCore","slug":"error-accessing-file-srcpath-ex-message","errorCode":null,"errorMessage":"Error accessing file '${srcPath}': ${ex.Message}","messagePattern":"Error accessing file '(.+?)': (.+?)","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs","lineNumber":215,"sourceCode":"        {\n            throw new ArgumentException($\"The values for {nameof(srcPath)} and {nameof(dstPath)} must not be the same.\");\n        }\n\n        try\n        {\n            await _amazonS3Client.GetObjectMetadataAsync(new GetObjectMetadataRequest\n            {\n                BucketName = _options.BucketName,\n                Key = this.Combine(_basePrefix, srcPath),\n            });\n        }\n        catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)\n        {\n            throw new FileStoreException($\"Cannot copy file '{srcPath}' because it does not exist.\");\n        }\n        catch (AmazonS3Exception ex)\n        {\n            throw new FileStoreException($\"Error accessing file '{srcPath}': {ex.Message}\", ex);\n        }\n\n        try\n        {\n            var listObjects = await _amazonS3Client.ListObjectsV2Async(new ListObjectsV2Request\n            {\n                BucketName = _options.BucketName,\n                Prefix = this.Combine(_basePrefix, dstPath),\n            });\n\n            if (listObjects.S3Objects?.Count > 0)\n            {\n                throw new ExistsFileStoreException($\"Cannot copy file '{srcPath}' because a file already exists in the new path '{dstPath}'.\");\n            }\n\n            var copyObjectResponse = await _amazonS3Client.CopyObjectAsync(new CopyObjectRequest\n            {\n                SourceBucket = _options.BucketName,","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs#L197-L233","documentation":"Any AmazonS3Exception raised by GetObjectMetadataAsync during CopyFileAsync that is not a 404 is wrapped in a FileStoreException carrying the S3 error message. This reports general S3 access failures (auth, permissions, network, throttling) while checking the source file.","triggerScenarios":"CopyFileAsync when GetObjectMetadataAsync throws: invalid credentials (403), missing s3 permissions, bucket in another region, network errors, throttling (503), or any non-NotFound S3 error.","commonSituations":"Wrong AccessKey/SecretKey, IAM policy lacks s3:GetObject/HeadObject, bucket region mismatch vs. service URL, expired credentials, transient AWS outages or rate limits.","solutions":["Read the inner exception message to identify the S3 error code and fix credentials/permissions accordingly.","Verify AWS credentials and IAM policy allow s3:GetObject (and HeadObject) on the bucket/prefix.","Ensure the configured region/service URL matches the bucket's region.","Retry with backoff if the error is throttling (SlowDown) or a transient 5xx."],"exampleFix":"// before\nawait fileStore.CopyFileAsync(srcPath, dstPath);\n\n// after\ntry\n{\n    await fileStore.CopyFileAsync(srcPath, dstPath);\n}\ncatch (FileStoreException ex)\n{\n    _logger.LogError(ex, \"S3 copy of '{Src}' failed\", srcPath);\n    throw;\n}","handlingStrategy":"try-catch","validationCode":"// Verify configuration before use\nif (string.IsNullOrEmpty(_awsOptions.BucketName) || string.IsNullOrEmpty(_awsOptions.AccessKey))\n{\n    throw new InvalidOperationException(\"AWS S3 storage is not configured.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await fileStore.CopyFileAsync(srcPath, dstPath);\n}\ncatch (FileStoreException ex)\n{\n    _logger.LogError(ex, \"S3 error during copy: {Message}\", ex.Message);\n    throw;\n}","preventionTips":["Grant IAM s3:GetObject/HeadObject on the bucket prefix.","Match the S3 service region to the bucket region.","Monitor credential expiry and rotate via roles instead of static keys."],"tags":["s3","aws","permissions","network"],"backgroundTag":"api-error-response","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"}