itsfatduck/optimizerDuck · error · StepExecutionException
Service verify failed for
Error message
Service verify failed for {ServiceName}: could not query the current startup type. What it means
ServiceRevertStep.ExecuteAsync throws this when, after the restore command reported success, the follow-up query GetStartupTypeAsync returns null startup type without the NotFound flag — meaning the sc.exe qc query itself failed. The step never reports an unverified restore, so a failed verification query is a hard failure.
Solutions
- Retry the revert — transient SCM/timeout failures usually clear.
- Verify the service still exists with sc query <ServiceName>; if deleted, the service is gone and the revert file can be discarded.
- Increase AppSettings.Optimize.ShellTimeoutMs if query timeouts are the cause, then retry.
- Check the Serilog log for the sc.exe stderr captured around the failure.
Defensive patterns
Strategy: retry
Validate before calling
var (type, notFound) = await ServiceProcessService.GetStartupTypeAsync(serviceName, logger);
if (!notFound && type is null) { /* query broken — fix environment first */ } Try / catch
catch (StepExecutionException ex) when (ex.Message.Contains("could not query the current startup type"))
{ await Task.Delay(2000); /* retry once */ } Prevention
- Avoid reverting under heavy system load or during service installs
- Increase ShellTimeoutMs if queries approach the 15s timeout
- Check the service was not deleted between command and verification
- Run elevated so sc qc never fails on permissions
When it happens
Trigger: Revert executed, then the verification query failed: Task/Service Control Manager temporarily unavailable, the service was deleted between the change and the query (race), timeout of the 15s query timeout, or sc.exe output not parseable due to unexpected locale/console corruption.
Common situations: Service removed by its updater right after the revert command ran; system under heavy load causing the 15-second query timeout; sc.exe output redirected/encoded unexpectedly.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- Service verify failed for
- result.Error ?? Description
- Scheduled task verify failed at
- Scheduled task verify failed at
- Missing required 'OriginalEnabled' in scheduled-task revert…
AI-assisted analysis of itsfatduck/optimizerDuck@36acf585ae (2026-09-13).
Data as JSON: /api/errors/bf9d436186561993.
Report an issue: GitHub.
Appendix: source
Thrown at optimizerDuck/Domain/Revert/Steps/ServiceRevertStep.cs:69
ServiceStrings.ServiceInfoSkippedAccessDenied,
ServiceName
);
if (string.Equals(result.Error, accessDenied, StringComparison.Ordinal))
return false;
throw new StepExecutionException(result.Error ?? Description, result.ErrorDetail);
}
var (actual, notFound) = await ServiceProcessService
.GetStartupTypeAsync(ServiceName, opCall.Logger)
.ConfigureAwait(false);
// a missing service has nothing to restore.
if (notFound)
return true;
// null without NotFound means the query failed; never report an unverified restore.
if (actual is null)
throw new StepExecutionException(
$"Service verify failed for {ServiceName}: could not query the current startup type.",
null
);
if (actual.Value != OriginalStartupType)
throw new StepExecutionException(
$"Service verify failed for {ServiceName}: expected {OriginalStartupType}, actual={actual.Value}",
null
);
return true;
}
/// <inheritdoc />
public JObject ToData()
{
return new JObject
{
[nameof(ServiceName)] = ServiceName,View on GitHub (pinned to 36acf585ae)