{"record":{"id":"4e4fcc1c133197a5","repo":"microsoft/aspire","slug":"32000-message","errorCode":"-32000","errorMessage":"message","messagePattern":"message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go","lineNumber":770,"sourceCode":"}\n\nfunc (c *client) onConnectionClose(_ error) {\n\tc.mu.Lock()\n\tc.conn = nil\n\tcallbacks := c.disconnectCallbacks\n\tc.disconnectCallbacks = nil\n\tc.mu.Unlock()\n\tfor _, cb := range callbacks {\n\t\tcb()\n\t}\n}\n\n// ── Package-level I/O helpers ─────────────────────────────────────────────────\n\nfunc extractResult(response map[string]any) (any, error) {\n\tif errObj, hasErr := response[\"error\"]; hasErr {\n\t\terrMap, _ := errObj.(map[string]any)\n\t\treturn nil, errors.New(getString(errMap, \"message\"))\n\t}\n\treturn response[\"result\"], nil\n}\n\nfunc writeMessage(w io.Writer, msg map[string]any) error {\n\tbody, err := json.Marshal(msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\theader := fmt.Sprintf(\"Content-Length: %d\\r\\n\\r\\n\", len(body))\n\tif _, err = w.Write([]byte(header)); err != nil {\n\t\treturn err\n\t}\n\t_, err = w.Write(body)\n\treturn err\n}\n\nfunc readMessage(reader *bufio.Reader) (map[string]any, error) {","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go#L752-L788","documentation":"extractResult converts a JSON-RPC response's \"error\" object into a Go error whose text is exactly the server-provided message string (code -32000 is the JSON-RPC server-error range; here the code is dropped and only the message is preserved). This is the generic channel for server-side failures raised by the AppHost while executing a capability or callback.","triggerScenarios":"Any request (invokeCapability, authenticate, cancelToken, ping) whose response map contains an \"error\" member — server-side capability exceptions, CapabilityError conditions surfaced before tryGetAtsError runs, callback dispatch failures (e.g. \"callback ID missing\" or \"callback not found: ...\" from error 2093's path, enqueued with code -32000).","commonSituations":"Server-side validation failures in a capability; invoking a capability with wrong argument shapes; AppHost raising exceptions during model building; callback invocation errors reported back through the JSON-RPC error field.","solutions":["Read the error message text — it is the AppHost server's own message and names the failing operation","Fix the capability arguments/API usage indicated by the message (wrong types, missing handles, invalid model operations)","If the message is a callback error, verify the referenced callback was registered and not nil","Upgrade the generated Go client and AppHost together to avoid protocol-shaped server errors"],"exampleFix":"// before\nresult, _ := conn.sendRequest(ctx, \"invokeCapability\", params) // server error surfaces later\n\n// after\nresult, err := conn.sendRequest(ctx, \"invokeCapability\", params)\nif err != nil {\n\tlog.Printf(\"apphost capability failed: %v\", err) // message from server error object\n\treturn err\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"result, err := capability(ctx, args)\nif err != nil {\n\t// err text is the AppHost server's message; log and inspect args/usage\n\tlog.Printf(\"apphost error: %v\", err)\n\treturn err\n}","preventionTips":["Validate capability arguments' types/shapes before invoking","Keep Go client and AppHost versions aligned","Read the error message — it names the server-side cause","Verify callbacks are registered and non-nil when handles reference them"],"tags":["go","rpc","jsonrpc","server-error","apphost"],"backgroundTag":"api-error-response","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"}