itsfatduck/optimizerDuck · error · StepExecutionException
Missing required 'OriginalEnabled' in scheduled-task revert…
Error message
Missing required 'OriginalEnabled' in scheduled-task revert data.
What it means
ScheduledTaskRevertStep.FromData throws this during deserialization when the persisted revert JSON lacks the OriginalEnabled field. The revert system is fail-closed: without knowing the original enabled state there is no safe way to undo, so it refuses to construct the step.
Solutions
- Re-apply the optimization so a fresh, complete revert file is written, then revert again.
- If the original state is known, edit the revert JSON to add "OriginalEnabled": true|false and retry.
- If the state is unknowable, delete the revert file %LocalAppData%\optimizerDuck\Revert\{id}.json (accepting the task stays in its current state).
- Restore the file from backup before editing.
Example fix
// before (revert JSON)
{ "Steps": [ { "$type": "ScheduledTaskRevertStep", "FullPath": "\\X\\Y" } ] }
// after
{ "Steps": [ { "$type": "ScheduledTaskRevertStep", "FullPath": "\\X\\Y", "OriginalEnabled": true } ] } Defensive patterns
Strategy: validation
Validate before calling
var json = File.ReadAllText(revertFile); var data = JObject.Parse(json); bool ok = data["Steps"]?.Any(s => s["OriginalEnabled"] != null) == true;
Type guard
static bool HasOriginalEnabled(JObject d) =>
d[nameof(ScheduledTaskRevertStep.OriginalEnabled)] is { Type: not JTokenType.Null }; Try / catch
try { var step = ScheduledTaskRevertStep.FromData(data); }
catch (StepExecutionException ex) when (ex.Message.Contains("OriginalEnabled"))
{ logger.LogError("Revert data incomplete; re-apply the optimization to regenerate it"); } Prevention
- Never hand-edit revert JSON; regenerate by re-applying
- Back up %LocalAppData%\optimizerDuck\Revert before upgrades
- Do not migrate revert files across app versions
- Rely on atomic writes; never truncate the file manually
When it happens
Trigger: Loading a revert file whose JSON was hand-edited, truncated, produced by an older app version that did not persist OriginalEnabled, or corrupted mid-write (though atomic writes make this unlikely). data["OriginalEnabled"] is null or JTokenType.Null.
Common situations: Manually editing %LocalAppData%\optimizerDuck\Revert\{id}.json and dropping the field; migrating revert data between app versions; a bug in an older build writing incomplete step data.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Scheduled task verify failed at
- Scheduled task verify failed at
- result.Error ?? Description
- Service verify failed for
- Service verify failed for
AI-assisted analysis of itsfatduck/optimizerDuck@36acf585ae (2026-09-13).
Data as JSON: /api/errors/e498a0647512e006.
Report an issue: GitHub.
Appendix: source
Thrown at optimizerDuck/Domain/Revert/Steps/ScheduledTaskRevertStep.cs:84
public JObject ToData()
{
return new JObject
{
[nameof(FullPath)] = FullPath,
[nameof(OriginalEnabled)] = OriginalEnabled,
};
}
/// <summary>
/// Deserializes a <see cref="ScheduledTaskRevertStep" /> from JSON data.
/// </summary>
/// <param name="data">The JSON data to deserialize.</param>
/// <returns>A new <see cref="ScheduledTaskRevertStep" /> instance.</returns>
public static ScheduledTaskRevertStep FromData(JObject data)
{
var enabledToken = data[nameof(OriginalEnabled)];
if (enabledToken == null || enabledToken.Type == JTokenType.Null)
throw new StepExecutionException(
$"Missing required '{nameof(OriginalEnabled)}' in scheduled-task revert data.",
data.ToString()
);
return new ScheduledTaskRevertStep
{
FullPath = data[nameof(FullPath)]?.ToString() ?? string.Empty,
OriginalEnabled = enabledToken.Value<bool>(),
};
}
}
View on GitHub (pinned to 36acf585ae)