{"record":{"id":"902cc917357ef5cd","repo":"LykosAI/StabilityMatrix","slug":"source-file-does-not-exist","errorCode":null,"errorMessage":"Source file does not exist","messagePattern":"Source file does not exist","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Inference/ComfyClient.cs","lineNumber":394,"sourceCode":"        CancellationToken cancellationToken = default\n    )\n    {\n        cancellationToken.ThrowIfCancellationRequested();\n\n        // Currently there is no api, so we do a local file copy\n        if (LocalServerPath is null)\n        {\n            throw new InvalidOperationException(\"LocalServerPath is not set\");\n        }\n\n        var sourceFile = new FilePath(sourcePath);\n        var destFile = LocalServerPath.JoinFile(destinationRelativePath);\n\n        Logger.Info(\"Copying file from {Source} to {Dest}\", sourcePath, destFile);\n\n        if (!sourceFile.Exists)\n        {\n            throw new FileNotFoundException(\"Source file does not exist\", sourcePath);\n        }\n\n        destFile.Directory?.Create();\n\n        await sourceFile.CopyToAsync(destFile, true).ConfigureAwait(false);\n    }\n\n    public async Task<Dictionary<string, List<ComfyImage>?>> GetImagesForExecutedPromptAsync(\n        string promptId,\n        CancellationToken cancellationToken = default\n    )\n    {\n        // Get history for images\n        var history = await comfyApi.GetHistory(promptId, cancellationToken).ConfigureAwait(false);\n\n        // Get the current prompt history\n        var current = history[promptId];\n","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Inference/ComfyClient.cs#L376-L412","documentation":"ComfyClient.UploadFileAsync uploads a local file to the ComfyUI server's input directory. Before copying it checks sourceFile.Exists and throws FileNotFoundException carrying both a message and the source path. The server-side upload cannot proceed without the local source, so the client fails fast.","triggerScenarios":"Calling UploadFileAsync (via UploadPromptFiles) with a sourcePath that does not exist — e.g. an image path referenced in a workflow prompt that was deleted, or a relative path from a workflow JSON that is invalid on this machine.","commonSituations":"Queueing a saved workflow that references input images not present on the new machine; paths from imported workflows built on another OS with different path separators.","solutions":["Check File.Exists(sourcePath) before calling UploadFileAsync and fail the prompt upload gracefully","Normalize/validate all file paths embedded in workflow prompts before queueing","Re-export or re-add the missing input asset","Catch FileNotFoundException in UploadPromptFiles and report which file is missing"],"exampleFix":"// before\nawait client.UploadFileAsync(sourcePath, destinationRelativePath);\n// after\nif (!File.Exists(sourcePath))\n{\n    Logger.Warn(\"Skipping upload, missing source: {Path}\", sourcePath);\n    return;\n}\nawait client.UploadFileAsync(sourcePath, destinationRelativePath);","handlingStrategy":"validation","validationCode":"foreach (var path in promptFilePaths)\n    if (!File.Exists(path)) throw new FileNotFoundException(\"Missing prompt input\", path);","typeGuard":"static bool Uploadable(string? p) => File.Exists(p) && new FileInfo(p).Length > 0;","tryCatchPattern":"try { await client.UploadFileAsync(sourcePath, destRelPath); }\ncatch (FileNotFoundException ex) { Logger.Warn(\"Upload aborted, missing: {File}\", ex.FileName); }","preventionTips":["Validate all workflow-referenced input paths before queueing prompts","Normalize paths from imported workflows for the current OS","Re-export workflows with assets on machines missing inputs","Fail whole-prompt uploads early with a clear missing-file list"],"tags":["csharp","network","comfyui","file-io"],"backgroundTag":"file-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}