{"record":{"id":"b18d04b92e56c197","repo":"geektutu/7days-golang","slug":"rpc-server-service-method-request-ill-formed-b18d04","errorCode":null,"errorMessage":"rpc server: service/method request ill-formed: ","messagePattern":"rpc server: service/method request ill-formed: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gee-rpc/day7-registry/server.go","lineNumber":116,"sourceCode":"\tmtype        *methodType\n\tsvc          *service\n}\n\nfunc (server *Server) readRequestHeader(cc codec.Codec) (*codec.Header, error) {\n\tvar h codec.Header\n\tif err := cc.ReadHeader(&h); err != nil {\n\t\tif err != io.EOF && err != io.ErrUnexpectedEOF {\n\t\t\tlog.Println(\"rpc server: read header error:\", err)\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn &h, nil\n}\n\nfunc (server *Server) findService(serviceMethod string) (svc *service, mtype *methodType, err error) {\n\tdot := strings.LastIndex(serviceMethod, \".\")\n\tif dot < 0 {\n\t\terr = errors.New(\"rpc server: service/method request ill-formed: \" + serviceMethod)\n\t\treturn\n\t}\n\tserviceName, methodName := serviceMethod[:dot], serviceMethod[dot+1:]\n\tsvci, ok := server.serviceMap.Load(serviceName)\n\tif !ok {\n\t\terr = errors.New(\"rpc server: can't find service \" + serviceName)\n\t\treturn\n\t}\n\tsvc = svci.(*service)\n\tmtype = svc.method[methodName]\n\tif mtype == nil {\n\t\terr = errors.New(\"rpc server: can't find method \" + methodName)\n\t}\n\treturn\n}\n\nfunc (server *Server) readRequest(cc codec.Codec) (*request, error) {\n\th, err := server.readRequestHeader(cc)","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-rpc/day7-registry/server.go#L98-L134","documentation":"The server's findService parses the request's ServiceMethod string as 'Service.Method'. If the string contains no dot, the library cannot split it and returns this error. It is sent back to the client as an error response.","triggerScenarios":"Calling a method where the ServiceMethod header lacks a '.' separator — e.g. passing just 'Foo' instead of 'Foo.Bar' as the method name to Call/XCall, or a client/server using a different method naming convention.","commonSituations":"Hand-writing the serviceMethod string instead of using a client wrapper; mixing this RPC framework with another whose wire format joins service and method differently; typos like 'FooBar' instead of 'Foo.Bar'.","solutions":["Pass the method name in 'Service.Method' form, e.g. \"Foo.Sum\" not \"Foo\" or \"FooSum\"","Check that the client library building the request matches this server's naming convention","Log the incoming ServiceMethod on the server and correct the caller's string"],"exampleFix":"// before\ncall.xf.Call(ctx, \"Foo\", args, &reply) // ill-formed\n// after\ncall.xf.Call(ctx, \"Foo.Sum\", args, &reply)","handlingStrategy":"validation","validationCode":"// validate the serviceMethod string before calling\nfunc validServiceMethod(sm string) bool {\n    parts := strings.Split(sm, \".\")\n    return len(parts) == 2 && parts[0] != \"\" && parts[1] != \"\"\n}\nif !validServiceMethod(\"Foo.Sum\") { /* reject before RPC */ }","typeGuard":null,"tryCatchPattern":"err := client.Call(\"Foo.Sum\", args, &reply)\nif err != nil && strings.Contains(err.Error(), \"ill-formed\") {\n    log.Fatalf(\"ServiceMethod must be 'Service.Method', got: %v\", err)\n}","preventionTips":["Centralize method-name construction in a typed helper instead of string literals","Add a unit test listing all callable 'Service.Method' names","Never join service and method with anything but a single dot"],"tags":["go","rpc","request-format"],"backgroundTag":"rpc-method-name-ill-formed","analyzedSha":"cf3644382101dc13e7fd92e8f5c66cabc51bcd3b","analyzedAt":"2026-09-03T18:31:24.087Z","contentChangedAt":"2026-09-03T18:31:24.087Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}