{"record":{"id":"a054b566ef56f02e","repo":"microsoft/aspire","slug":"failed-to-send-request-method-e-getmessage","errorCode":null,"errorMessage":"Failed to send request {method}: {e.getMessage()}","messagePattern":"Failed to send request (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.CodeGeneration.Java/Resources/Transport.java","lineNumber":440,"sourceCode":"\n        Map<String, Object> request = new HashMap<>();\n        request.put(\"jsonrpc\", \"2.0\");\n        request.put(\"id\", id);\n        request.put(\"method\", method);\n        request.put(\"params\", params);\n\n        debug(\"Sending request \" + method + \" with id=\" + id);\n\n        try {\n            ensureReaderLoopStarted();\n            sendMessage(request);\n            if (requestSent != null) {\n                requestSent.run();\n            }\n        } catch (IOException e) {\n            pendingRequests.remove(id);\n            handleDisconnect();\n            throw new RuntimeException(\"Failed to send request \" + method + \": \" + e.getMessage(), e);\n        }\n\n        try {\n            Object result = pendingResponse.join();\n            return unwrapResult(result);\n        } catch (CompletionException completionException) {\n            Throwable cause = completionException.getCause();\n            if (cause instanceof RuntimeException runtimeException) {\n                throw runtimeException;\n            }\n            throw new RuntimeException(\"Request \" + method + \" failed\", cause);\n        }\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private Object marshalTransportValue(Object value) {\n        return marshalTransportValue(value, null);\n    }","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.Java/Resources/Transport.java#L422-L458","documentation":"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.","triggerScenarios":"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>.","commonSituations":"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.","solutions":["Pass the dependency step's Name string, e.g. dependsOn: \"build\".","Pass a string collection: dependsOn: new[] { \"build\", \"restore\" } — convert generic collections with .Select(s => s.Name).ToList() if you have step objects.","Use the requiredBy parameter (same string/IEnumerable<string> rules) if the direction of the edge was reversed.","Fix at compile time where possible by storing step names as string constants instead of step objects."],"exampleFix":"// before\npipeline.AddStep(\"package\", Build, dependsOn: buildStep); // PipelineStep object\n// after\npipeline.AddStep(\"package\", Build, dependsOn: buildStep.Name); // string","handlingStrategy":"type-guard","validationCode":"// C#: validate dependsOn type before calling AddStep\nbool IsValidDependency(object? dependsOn) =>\n    dependsOn is null or string or IEnumerable<string>;","typeGuard":"static bool IsStringOrStringEnumerable(object? value) =>\n    value is string or IEnumerable<string>;","tryCatchPattern":"try\n{\n    pipeline.AddStep(name, action, dependsOn: dependency);\n}\ncatch (ArgumentException ex) when (ex.ParamName == nameof(PipelineStepContext) || ex.Message.Contains(\"dependsOn parameter\"))\n{\n    logger.LogError(ex, \"dependsOn must be string or IEnumerable<string>, got {Type}\", dependency?.GetType().Name);\n}","preventionTips":["Store dependency references as step-name strings, not PipelineStep objects.","Convert collections of steps with .Select(s => s.Name).ToArray() before passing.","Never pass non-generic IEnumerable or Dictionary as dependsOn/requiredBy."],"tags":["pipeline","argument-type","aspire","dependency"],"backgroundTag":"type-mismatch","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}