{"record":{"id":"bea3d8fb707a80ee","repo":"go-delve/delve","slug":"unknown-api-version","errorCode":null,"errorMessage":"unknown API version","messagePattern":"unknown API version","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/rpccommon/server.go","lineNumber":114,"sourceCode":"\t}\n\tif s.debugger.IsRunning() {\n\t\ts.debugger.Command(&api.DebuggerCommand{Name: api.Halt}, nil, nil, nil)\n\t}\n\tkill := s.config.Debugger.AttachPid == 0\n\treturn s.debugger.Detach(kill)\n}\n\n// Run starts a debugger and exposes it with an JSON-RPC server. The debugger\n// itself can be stopped with the `detach` API.\nfunc (s *ServerImpl) Run() error {\n\tvar err error\n\n\tif s.config.APIVersion == 0 {\n\t\ts.config.APIVersion = 2\n\t}\n\n\tif s.config.APIVersion != 2 {\n\t\treturn errors.New(\"unknown API version\")\n\t}\n\n\t// Create and start the debugger\n\tconfig := s.config.Debugger\n\tif s.debugger, err = debugger.New(&config, s.config.ProcessArgs); err != nil {\n\t\treturn err\n\t}\n\n\ts.s2 = rpc2.NewServer(s.config, s.debugger)\n\n\trpcServer := &RPCServer{s}\n\n\ts.methodMaps = make([]map[string]*methodType, 2)\n\n\ts.methodMaps[1] = map[string]*methodType{}\n\n\tsuitableMethods2(s.s2, s.methodMaps[1])\n\tsuitableMethodsCommon(rpcServer, s.methodMaps[1])","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/rpccommon/server.go#L96-L132","documentation":"rpccommon.Server.Run validates config.APIVersion and only serves version 2 (a default of 2 is applied when it is 0). Any other configured version causes startup to fail with 'unknown API version'.","triggerScenarios":"Creating/starting a rpccommon.Server with config.APIVersion set to anything other than 0 or 2 (e.g. 1 or 3).","commonSituations":"Embedding Delve in another tool with an older config that used APIVersion 1, or guessing a newer version number.","solutions":["Set config.APIVersion = 2 (or leave it 0 to get the default).","Remove stale APIVersion settings from embedded configs.","If version 1 behavior is needed, use a Delve release that still supports it."],"exampleFix":"// before\ncfg := &service.Config{APIVersion: 1}\n// after\ncfg := &service.Config{APIVersion: 2}","handlingStrategy":"validation","validationCode":"if cfg.APIVersion != 0 && cfg.APIVersion != 2 {\n    cfg.APIVersion = 2\n}","typeGuard":null,"tryCatchPattern":"if err := srv.Run(); err != nil {\n    if strings.Contains(err.Error(), \"unknown API version\") {\n        // fix config and restart server\n    }\n}","preventionTips":["Leave APIVersion at zero or set exactly 2.","Migrate old configs referencing v1.","Validate embedded Delve configs at startup."],"tags":["go","rpc","config","api-version","startup"],"backgroundTag":"unsupported-api-version","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}