LykosAI/StabilityMatrix · error · InvalidOperationException
InputImagesDir is null
Error message
InputImagesDir is null
What it means
UploadInputImageAsync throws this when the connected client reports no InputImagesDir (the ComfyUI server did not advertise an input images directory). The method early-returns if not connected, so this error only fires on a connected client whose input directory mapping is missing — an unexpected server state.
Solutions
- Ensure the ComfyUI server exposes its input directory (standard installation/layout)
- Fully connect and load shared model/paths info (ConnectAsync + LoadSharedPropertiesAsync) before uploading
- Check the server's folder configuration for a missing input directory mapping
- Update Stability Matrix or the backend package if versions mismatch
Example fix
// before
await clientManager.UploadInputImageAsync(image, "input.png");
// after
await clientManager.ConnectAsync();
await clientManager.LoadSharedPropertiesAsync();
if (clientManager.Client?.InputImagesDir is null)
throw new InvalidOperationException("Server did not report an input images directory");
await clientManager.UploadInputImageAsync(image, "input.png"); Defensive patterns
Strategy: validation
Validate before calling
if (clientManager.Client?.InputImagesDir is null)
throw new InvalidOperationException("Backend did not expose an input images directory"); Type guard
bool HasInputDir(InferenceClientManager m) => m.Client?.InputImagesDir is not null;
Try / catch
try
{
await clientManager.UploadInputImageAsync(image, name);
}
catch (InvalidOperationException ex) when (ex.Message == "InputImagesDir is null")
{
// surface a setup error: backend folder config incomplete
} Prevention
- Complete full connection setup before uploading
- Use standard ComfyUI folder layouts
- Update backend/Stability Matrix to compatible versions
When it happens
Trigger: Calling UploadInputImageAsync on a client whose SharedModel/ComfyApi connection lacks InputImagesDir — e.g. server version without the expected folder mapping, or shared-model metadata not fully loaded.
Common situations: Connecting to an unusual or partially initialized ComfyUI deployment; server started with a nonstandard input directory config; using an older/newer backend whose API surface differs from what the manager expects.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Client is not connected
- Failed to get bitmap from image
- Client is not connected
- Prompt extensions not installed
- Failed to parse parameters
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/cbfeaf24bdb5b381.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/Services/InferenceClientManager.cs:803
// Encode mask to PNG
using var data = maskImage.Encode(SkiaSharp.SKEncodedImageFormat.Png, 100);
using var stream = new MemoryStream();
data.SaveTo(stream);
stream.Position = 0;
await Client.UploadImageAsync(stream, fileName, cancellationToken);
}
/// <inheritdoc />
public async Task CopyImageToInputAsync(FilePath imageFile, CancellationToken cancellationToken = default)
{
if (!IsConnected)
return;
if (Client.InputImagesDir is not { } inputImagesDir)
{
throw new InvalidOperationException("InputImagesDir is null");
}
var inferenceInputs = inputImagesDir.JoinDir("Inference");
inferenceInputs.Create();
var destination = inferenceInputs.JoinFile(imageFile.Name);
// Read to SKImage then write to file, to prevent errors from metadata
await Task.Run(
() =>
{
using var imageStream = imageFile.Info.OpenRead();
using var image = SKImage.FromEncodedData(imageStream);
using var destinationStream = destination.Info.OpenWrite();
image.Encode(SKEncodedImageFormat.Png, 100).SaveTo(destinationStream);
},
cancellationToken
);View on GitHub (pinned to af93d6ef57)