Skip to content

ServiceManager.GetServiceStartupType: catch-all returns ambiguous null #345

@Christophe-Rogiers

Description

@Christophe-Rogiers

Description

In src/Servy.Core/Services/ServiceManager.cs (lines 812–816):

catch (Exception ex)
{
    Logger.Error($"Error getting service startup type for '{serviceName}'.", ex);
    return null;
}

The error is logged, but null is returned. The same null is also returned in the normal default case (line 808) when the startup type is unrecognized.

The caller cannot distinguish between "service doesn't exist / unknown type" (normal) and "query failed due to SCM error" (problem). Both return null.

Severity

Info — ambiguous return value; logged but operationally indistinguishable.

Suggested fix

Consider using a nullable enum with a distinct "Unknown" / "Error" value, or let the exception propagate for callers that need to handle SCM failures differently.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions