{"record":{"id":"25fae9dcff6f9b56","repo":"micro/go-micro","slug":"reflection-lookup-for-s-returned-t","errorCode":null,"errorMessage":"reflection lookup for %s returned %T","messagePattern":"reflection lookup for (.+?) returned %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gateway/mcp/grpcreflect.go","lineNumber":163,"sourceCode":"\t}\n\treturn files, services, nil\n}\n\nfunc requestFileContainingSymbol(ctx context.Context, client reflectionpb.ServerReflectionClient, symbol string, set *descriptorpb.FileDescriptorSet, seen map[string]bool) error {\n\tstream, err := client.ServerReflectionInfo(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := stream.Send(&reflectionpb.ServerReflectionRequest{MessageRequest: &reflectionpb.ServerReflectionRequest_FileContainingSymbol{FileContainingSymbol: symbol}}); err != nil {\n\t\treturn err\n\t}\n\tresp, err := stream.Recv()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfd := resp.GetFileDescriptorResponse()\n\tif fd == nil {\n\t\treturn fmt.Errorf(\"reflection lookup for %s returned %T\", symbol, resp.MessageResponse)\n\t}\n\tfor _, raw := range fd.FileDescriptorProto {\n\t\tvar file descriptorpb.FileDescriptorProto\n\t\tif err := proto.Unmarshal(raw, &file); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tname := file.GetName()\n\t\tif !seen[name] {\n\t\t\tseen[name] = true\n\t\t\tset.File = append(set.File, &file)\n\t\t}\n\t}\n\treturn nil\n}\n\n// protoregistryFiles is a narrow wrapper that keeps imports local to this file.\ntype protoregistryFiles struct{ files *protoregistry.Files }\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/gateway/mcp/grpcreflect.go#L145-L181","documentation":"requestFileContainingSymbol asks the reflection stream for the file descriptor containing a given symbol and expects a FileDescriptorResponse. If the reply is a different MessageResponse variant (typically ErrorResponse, meaning the server does not know the symbol), this error reports the unexpected type received for that symbol.","triggerScenarios":"loadReflectedFiles resolving each listed service via requestFileContainingSymbol, and stream.Recv() returns a response whose GetFileDescriptorResponse() is nil — commonly an ErrorResponse for SYMBOL_TO_FILE_CONTAINING_SYMBOL.","commonSituations":"Server reflection enabled but built from different .proto files than the client expects (symbol not found); nested/legacy symbols the server cannot resolve; services registered without the corresponding descriptor source.","solutions":["Inspect the ErrorResponse text (log the %T and the response's error message) to see why the symbol lookup failed.","Ensure the server binary was built with the same .proto definitions it serves, so symbols resolve.","Verify the symbol name format passed to requestFileContainingSymbol (fully qualified package.Service).","Fall back to supplying descriptor sets (FileDescriptorSet) instead of per-symbol reflection if the server cannot resolve symbols."],"exampleFix":"// before\nsymbol := \"MyService\" // not fully qualified\n// after\nsymbol := \"mypackage.MyService\" // fully qualified symbol resolves via reflection","handlingStrategy":"type-guard","validationCode":"if !strings.Contains(symbol, \".\") {\n    return fmt.Errorf(\"symbol %q must be fully qualified (package.Service)\", symbol)\n}","typeGuard":"func asFileDescriptor(resp *refpb.ServerReflectionResponse) *refpb.FileDescriptorResponse {\n    if fd := resp.GetFileDescriptorResponse(); fd != nil {\n        return fd\n    }\n    if errResp := resp.GetErrorResponse(); errResp != nil {\n        log.Printf(\"symbol lookup failed: %s\", errResp.GetErrorText())\n    }\n    return nil\n}","tryCatchPattern":"if err := requestFileContainingSymbol(ctx, stream, symbol); err != nil {\n    if strings.Contains(err.Error(), \"returned refpb.ServerReflectionError\") {\n        return fmt.Errorf(\"server cannot resolve %s; check descriptor build parity: %w\", symbol, err)\n    }\n    return err\n}","preventionTips":["Build server and discovery client from the same .proto sources.","Always pass fully qualified symbol names (package.Service).","Handle the ErrorResponse variant for SYMBOL_TO_FILE requests explicitly.","Fall back to bundled FileDescriptorSets when the server cannot resolve a symbol."],"tags":["grpc","reflection","symbol-lookup","protocol-mismatch"],"backgroundTag":"grpc-reflection-symbol-not-found","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}