Tichau/FileConverter · error · Exception
The conversion preset must be valid.
Error message
The conversion preset must be valid.
What it means
ConversionJob_Gif.Convert() throws Exception when this.ConversionPreset is null before delegating to its child jobs (an optional pngConversionJob to normalize the input image and a ConversionJob_FFMPEG that builds the GIF). The job constructs its FFMPEG child from this.ConversionPreset in Initialize(), so a null preset would propagate NREs into the child; the guard fails fast instead. Like the sibling jobs, the real ctor blocks null presets, so this fires only via the parameterless design-mode ctor or direct/reflection invocation of Convert().
Source
Thrown at Application/FileConverter/ConversionJobs/ConversionJob_Gif.cs:70
this.pngConversionJob.PrepareConversion(this.intermediateFilePath);
inputFilePath = this.intermediateFilePath;
}
else
{
inputFilePath = this.InputFilePath;
}
// Convert png file into ico.
this.gifConversionJob = new ConversionJob_FFMPEG(this.ConversionPreset, inputFilePath);
this.gifConversionJob.PrepareConversion(this.OutputFilePath);
}
protected override void Convert()
{
if (this.ConversionPreset == null)
{
throw new Exception("The conversion preset must be valid.");
}
Task updateProgress = this.UpdateProgress();
if (this.pngConversionJob != null)
{
this.UserState = Properties.Resources.ConversionStateReadIntputImage;
Diagnostics.Debug.Log(string.Empty);
Diagnostics.Debug.Log("Convert image to PNG (intermediate format).");
this.pngConversionJob.StartConversion();
if (this.pngConversionJob.State != ConversionState.Done)
{
this.ConversionFailed(this.pngConversionJob.ErrorMessage);
return;
}
}View on GitHub (pinned to 6c157a411f)
Solutions
- Construct via new ConversionJob_Gif(conversionPreset, inputFilePath) or ConversionJobFactory.Create.
- Drive the job through PrepareConversion() + StartConversion(), not Convert().
- Early-return in design-time when ConversionPreset is null.
- Confirm preset loading succeeded before creating the job.
Example fix
// before var job = new ConversionJob_Gif(); job.Convert(); // throws: preset null // after var job = ConversionJobFactory.Create(conversionPreset, inputFilePath); job.PrepareConversion(outputFilePath); job.StartConversion();
Defensive patterns
Strategy: validation
Validate before calling
if (job == null || job.ConversionPreset == null)
{
throw new InvalidOperationException(
"ConversionJob_Gif requires a non-null ConversionPreset; use the (preset, inputFilePath) constructor.");
}
job.StartConversion(); Type guard
private static bool HasValidPreset(ConversionJob job) => job != null && job.ConversionPreset != null;
Try / catch
try
{
job.StartConversion();
}
catch (Exception ex) when (ex.Message.Contains("conversion preset must be valid"))
{
logger.Error(ex, "GIF job created without a preset.");
job = new ConversionJob_Gif(LoadPreset(), inputPath);
} Prevention
- Construct GIF jobs via ConversionJobFactory.Create or the (preset, path) ctor.
- Drive execution through StartConversion(), not Convert().
- Load the image-output preset before creating the job.
- Reserve the parameterless ctor for XAML design time.
When it happens
Trigger: ConversionJob_Gif built via its parameterless ctor then Convert() invoked; or reflection calling Convert() on an instance whose preset is null. Initialize() already uses this.ConversionPreset to construct the FFMPEG child, so a null would also break initialization earlier.
Common situations: XAML design-time instantiation; unit tests exercising Convert() directly; a pipeline that created the GIF job before the image-output preset was loaded.
Related errors
- The conversion preset must be valid.
- The conversion preset must be valid.
- The conversion preset must be valid.
- The conversion preset must be valid.
- The conversion preset must be valid.
AI-assisted analysis of Tichau/FileConverter@6c157a411f (2026-08-13).
Data as JSON: /api/errors/f003312a95158a8c.
Report an issue: GitHub.