LykosAI/StabilityMatrix · error · FileNotFoundException
Source file does not exist
Error message
Source file does not exist
What it means
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.
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
Example fix
// before
await client.UploadFileAsync(sourcePath, destinationRelativePath);
// after
if (!File.Exists(sourcePath))
{
Logger.Warn("Skipping upload, missing source: {Path}", sourcePath);
return;
}
await client.UploadFileAsync(sourcePath, destinationRelativePath); Defensive patterns
Strategy: validation
Validate before calling
foreach (var path in promptFilePaths)
if (!File.Exists(path)) throw new FileNotFoundException("Missing prompt input", path); Type guard
static bool Uploadable(string? p) => File.Exists(p) && new FileInfo(p).Length > 0;
Try / catch
try { await client.UploadFileAsync(sourcePath, destRelPath); }
catch (FileNotFoundException ex) { Logger.Warn("Upload aborted, missing: {File}", ex.FileName); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Sampler not selected
- : Model not selected
- Scheduler not selected
- BaseClipVision not set
- Source directory not found
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/902cc917357ef5cd.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Inference/ComfyClient.cs:394
CancellationToken cancellationToken = default
)
{
cancellationToken.ThrowIfCancellationRequested();
// Currently there is no api, so we do a local file copy
if (LocalServerPath is null)
{
throw new InvalidOperationException("LocalServerPath is not set");
}
var sourceFile = new FilePath(sourcePath);
var destFile = LocalServerPath.JoinFile(destinationRelativePath);
Logger.Info("Copying file from {Source} to {Dest}", sourcePath, destFile);
if (!sourceFile.Exists)
{
throw new FileNotFoundException("Source file does not exist", sourcePath);
}
destFile.Directory?.Create();
await sourceFile.CopyToAsync(destFile, true).ConfigureAwait(false);
}
public async Task<Dictionary<string, List<ComfyImage>?>> GetImagesForExecutedPromptAsync(
string promptId,
CancellationToken cancellationToken = default
)
{
// Get history for images
var history = await comfyApi.GetHistory(promptId, cancellationToken).ConfigureAwait(false);
// Get the current prompt history
var current = history[promptId];
View on GitHub (pinned to af93d6ef57)