microsoft/aspire · error · RuntimeException

Failed to send request

Error message

Failed to send request {method}: {e.getMessage()}

What it means

AddStep's dependsOn parameter is typed object? for caller convenience but only supports a single step-name string or an IEnumerable<string> of names. The private AddDependencies helper pattern-matches the value and throws ArgumentException when the runtime type is neither, naming the actual type received.

Solutions

  1. Pass the dependency step's Name string, e.g. dependsOn: "build".
  2. Pass a string collection: dependsOn: new[] { "build", "restore" } — convert generic collections with .Select(s => s.Name).ToList() if you have step objects.
  3. Use the requiredBy parameter (same string/IEnumerable<string> rules) if the direction of the edge was reversed.
  4. Fix at compile time where possible by storing step names as string constants instead of step objects.

Example fix

// before
pipeline.AddStep("package", Build, dependsOn: buildStep); // PipelineStep object
// after
pipeline.AddStep("package", Build, dependsOn: buildStep.Name); // string
Defensive patterns

Strategy: type-guard

Validate before calling

// C#: validate dependsOn type before calling AddStep
bool IsValidDependency(object? dependsOn) =>
    dependsOn is null or string or IEnumerable<string>;

Type guard

static bool IsStringOrStringEnumerable(object? value) =>
    value is string or IEnumerable<string>;

Try / catch

try
{
    pipeline.AddStep(name, action, dependsOn: dependency);
}
catch (ArgumentException ex) when (ex.ParamName == nameof(PipelineStepContext) || ex.Message.Contains("dependsOn parameter"))
{
    logger.LogError(ex, "dependsOn must be string or IEnumerable<string>, got {Type}", dependency?.GetType().Name);
}

Prevention

When it happens

Trigger: Calling AddStep with dependsOn set to a PipelineStep instance, an object (not string), a single-element non-string collection, a Dictionary, or null-wrapped value types — anything that is not string or IEnumerable<string>.

Common situations: Passing a PipelineStep object instead of its Name string; passing a HashSet<string> or LINQ query wrapped in a type that isn't IEnumerable<string> (e.g. non-generic IEnumerable or IEnumerable<object>); converting code from an API that accepted step references.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/a054b566ef56f02e. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.CodeGeneration.Java/Resources/Transport.java:440

        Map<String, Object> request = new HashMap<>();
        request.put("jsonrpc", "2.0");
        request.put("id", id);
        request.put("method", method);
        request.put("params", params);

        debug("Sending request " + method + " with id=" + id);

        try {
            ensureReaderLoopStarted();
            sendMessage(request);
            if (requestSent != null) {
                requestSent.run();
            }
        } catch (IOException e) {
            pendingRequests.remove(id);
            handleDisconnect();
            throw new RuntimeException("Failed to send request " + method + ": " + e.getMessage(), e);
        }

        try {
            Object result = pendingResponse.join();
            return unwrapResult(result);
        } catch (CompletionException completionException) {
            Throwable cause = completionException.getCause();
            if (cause instanceof RuntimeException runtimeException) {
                throw runtimeException;
            }
            throw new RuntimeException("Request " + method + " failed", cause);
        }
    }

    @SuppressWarnings("unchecked")
    private Object marshalTransportValue(Object value) {
        return marshalTransportValue(value, null);
    }

View on GitHub (pinned to 25830f84bd)