{"record":{"id":"b678bbf3133a0ee0","repo":"microsoft/aspire","slug":"aspire-createbuilder-returned-unexpected-type-t","errorCode":null,"errorMessage":"aspire: createBuilder returned unexpected type %T","messagePattern":"aspire: createBuilder returned unexpected type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs","lineNumber":2068,"sourceCode":"        // directory (not the cwd) when matching --apphost <directory> requests.\n        WriteLine(\"\\tif projectDirectory, ok := resolved[\\\"ProjectDirectory\\\"].(string); !ok || projectDirectory == \\\"\\\" {\");\n        WriteLine(\"\\t\\tif projectDirectory := os.Getenv(\\\"ASPIRE_PROJECT_DIRECTORY\\\"); projectDirectory != \\\"\\\" {\");\n        WriteLine(\"\\t\\t\\tresolved[\\\"ProjectDirectory\\\"] = projectDirectory\");\n        WriteLine(\"\\t\\t} else if pwd, err := os.Getwd(); err == nil {\");\n        WriteLine(\"\\t\\t\\tresolved[\\\"ProjectDirectory\\\"] = pwd\");\n        WriteLine(\"\\t\\t}\");\n        WriteLine(\"\\t}\");\n        WriteLine(\"\\tif appHostFilePath, ok := resolved[\\\"AppHostFilePath\\\"].(string); !ok || appHostFilePath == \\\"\\\" {\");\n        WriteLine(\"\\t\\tif appHostFilePath := os.Getenv(\\\"ASPIRE_APPHOST_FILEPATH\\\"); appHostFilePath != \\\"\\\" { resolved[\\\"AppHostFilePath\\\"] = appHostFilePath }\");\n        WriteLine(\"\\t}\");\n        WriteLine(\"\\tif dashboardApplicationName, ok := resolved[\\\"DashboardApplicationName\\\"].(string); ok && dashboardApplicationName == \\\"\\\" {\");\n        WriteLine(\"\\t\\tdelete(resolved, \\\"DashboardApplicationName\\\")\");\n        WriteLine(\"\\t}\");\n        WriteLine();\n        WriteLine($\"\\tresult, err := c.invokeCapability(context.Background(), \\\"{AtsConstants.CreateBuilderCapability}\\\", map[string]any{{\\\"argsOrOptions\\\": resolved}})\");\n        WriteLine(\"\\tif err != nil { return nil, err }\");\n        WriteLine(\"\\thref, ok := result.(handleReference)\");\n        WriteLine(\"\\tif !ok { return nil, fmt.Errorf(\\\"aspire: createBuilder returned unexpected type %T\\\", result) }\");\n        WriteLine($\"\\treturn &{builderImpl}{{resourceBuilderBase: newResourceBuilderBase(href.getHandle(), c)}}, nil\");\n        WriteLine(\"}\");\n        WriteLine();\n    }\n\n    private string? GetCreateBuilderOptionsType(AtsContext context)\n    {\n        // The TypeScript generator uses a DTO named \"CreateBuilderOptions\" for\n        // the createBuilder parameter; mirror that.\n        foreach (var dto in context.DtoTypes)\n        {\n            if (dto.Name.Equals(\"CreateBuilderOptions\", StringComparison.Ordinal)\n                && _dtoNames.TryGetValue(dto.TypeId, out var goName))\n            {\n                return goName;\n            }\n        }\n        return null;","sourceCodeStart":2050,"sourceCodeEnd":2086,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs#L2050-L2086","documentation":"The generated CreateBuilder() invokes the 'createBuilder' capability and expects the result to be a handleReference identifying the new builder. If the returned value is not a handleReference, this error is returned. It guards the initial handshake of the Go client against contract/shape drift.","triggerScenarios":"Calling CreateBuilder() (or CreateBuilderWithOptions) when the remote createBuilder capability returns nil or a non-handle value.","commonSituations":"Mismatched AppHost/generated-client versions, an AppHost that errored during builder creation but returned a non-standard payload, or protocol changes without regeneration.","solutions":["Regenerate the Go client from the current AppHost definitions","Update the aspire CLI/AppHost and the generated Go package to the same version","Inspect AppHost logs to see the actual createBuilder response"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"b, err := CreateBuilder()\nif err != nil {\n\treturn fmt.Errorf(\"createBuilder failed: %w\", err)\n}","preventionTips":["Regenerate the client when AppHost capability signatures change","Match aspire CLI/AppHost and generated package versions","Verify the AppHost is healthy before calling CreateBuilder"],"tags":["go","code-generation","type-assertion","version-mismatch"],"backgroundTag":"unexpected-response-shape","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"}