{"record":{"id":"a8925c0c78f6584c","repo":"geektutu/7days-golang","slug":"rpc-server-service-method-request-ill-formed-a8925c","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/day5-http-debug/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/day5-http-debug/server.go#L98-L134","documentation":"findService parses the service method name as \"Service.Method\" using the last dot as separator. If the string contains no dot at all, the server cannot split it and returns this ill-formed request error before looking anything up.","triggerScenarios":"A client calls Client.Call with a method name missing the \"Service.Method\" form, e.g. Call(\"Foo\", ...) instead of Call(\"Foo.Bar\", ...), or an HTTP-mode request whose path/decorated name is not normalized to include the dot.","commonSituations":"Typo or copy-paste dropping the method part, callers of Go's stdlib net/rpc migrating to gee-rpc assuming single-token names, or HTTP-mode calls where the path was not translated via the xshared/XPrt wrapper that appends the service name.","solutions":["Pass the full \"ServiceName.MethodName\" string to Call, e.g. Call(\"DemoService.Div\", args, reply)","Verify the registered service name matches what the client sends (Register derives it from the receiver's type name)","Check the server log or registration output for the exact registered service and method names"],"exampleFix":"// before\nclient.Call(\"Div\", args, reply)\n// after\nclient.Call(\"DemoService.Div\", args, reply)","handlingStrategy":"validation","validationCode":"func validateServiceMethod(name string) error {\n    if !strings.Contains(name, \".\") {\n        return fmt.Errorf(\"method name must be \\\"Service.Method\\\", got %q\", name)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := validateServiceMethod(method); err != nil {\n    return err\n}\nif err := client.Call(method, args, reply); err != nil {\n    if strings.Contains(err.Error(), \"ill-formed\") {\n        return fmt.Errorf(\"rpc method %q must be in Service.Method form: %w\", method, err)\n    }\n    return err\n}","preventionTips":["Always construct method names as constants like const Div = \"DemoService.Div\"","Keep a table of registered Service.Method names shared between server and client code","Code-review every Call site for the dot separator"],"tags":["rpc","request","validation"],"backgroundTag":"rpc-ill-formed-service-method","analyzedSha":"cf3644382101dc13e7fd92e8f5c66cabc51bcd3b","analyzedAt":"2026-09-03T18:31:24.087Z","contentChangedAt":"2026-09-03T18:31:24.087Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}