{"record":{"id":"3056c0a62dbd11ec","repo":"OrchardCMS/OrchardCore","slug":"the-values-for-nameof-srcpath-and-nameof-dstpath-must-not-be-3056c0","errorCode":null,"errorMessage":"The values for {nameof(srcPath)} and {nameof(dstPath)} must not be the same.","messagePattern":"The values for (.+?) and (.+?) must not be the same\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":585,"sourceCode":"\n        try\n        {\n            await CopyFileAsync(oldPath, newPath);\n            await TryDeleteFileAsync(oldPath);\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot move file '{oldPath}' to '{newPath}'.\", ex);\n        }\n    }\n\n    public async Task CopyFileAsync(string srcPath, string dstPath)\n    {\n        try\n        {\n            if (srcPath == dstPath)\n            {\n                throw new ArgumentException($\"The values for {nameof(srcPath)} and {nameof(dstPath)} must not be the same.\");\n            }\n\n            var oldBlob = GetBlobReference(srcPath);\n            var newBlob = GetBlobReference(dstPath);\n\n            if (!await oldBlob.ExistsAsync())\n            {\n                throw new FileStoreException($\"Cannot copy file '{srcPath}' because it does not exist.\");\n            }\n\n            if (await newBlob.ExistsAsync())\n            {\n                throw new FileStoreException($\"Cannot copy file '{srcPath}' because a file already exists in the new path '{dstPath}'.\");\n            }\n\n            await newBlob.StartCopyFromUriAsync(oldBlob.Uri);\n\n            await Task.Delay(250);","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L567-L603","documentation":"CopyFileAsync rejects a copy whose source and destination paths are equal, throwing ArgumentException. A copy onto itself is a no-op at best and a data hazard at worst, so the library fails fast before any Azure call.","triggerScenarios":"Calling IFileStore.CopyFileAsync(path, path) with identical strings; also surfaces via MoveFileAsync when oldPath == newPath.","commonSituations":"Off-by-one or normalization bugs where both arguments derive from the same variable; UI passes the same folder/filename for source and target in rename dialogs.","solutions":["Compare and skip the operation when srcPath == dstPath.","Normalize paths (case, slashes) before comparing if paths come from different sources.","Fix the caller logic that produces identical source and destination."],"exampleFix":"// before\nawait _fileStore.CopyFileAsync(path, path);\n// after\nif (srcPath != dstPath)\n{\n    await _fileStore.CopyFileAsync(srcPath, dstPath);\n}","handlingStrategy":"validation","validationCode":"if (string.Equals(srcPath, dstPath, StringComparison.Ordinal))\n{\n    return; // nothing to copy\n}\nawait _fileStore.CopyFileAsync(srcPath, dstPath);","typeGuard":"bool isRealCopy(string src, string dst) => !string.Equals(src, dst, StringComparison.Ordinal);","tryCatchPattern":"try\n{\n    await _fileStore.CopyFileAsync(srcPath, dstPath);\n}\ncatch (ArgumentException ex)\n{\n    _logger.LogWarning(ex, \"Source and destination must differ\");\n}","preventionTips":["Compare normalized paths (trim, unify slashes) before copying.","Never pass the same variable as both arguments.","In rename/move UIs, reject a target equal to the source."],"tags":["azure-blob","file-storage","argument-validation"],"backgroundTag":"invalid-argument-value","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"}