{"record":{"id":"8881ed6e5ad89764","repo":"netbirdio/netbird","slug":"failed-to-get-log-level-v","errorCode":null,"errorMessage":"failed to get log level: %v","messagePattern":"failed to get log level: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/debug.go","lineNumber":264,"sourceCode":"\t}\n\tdefer func() {\n\t\tif err := conn.Close(); err != nil {\n\t\t\tlog.Errorf(errCloseConnection, err)\n\t\t}\n\t}()\n\n\tclient := proto.NewDaemonServiceClient(conn)\n\n\tstat, err := client.Status(cmd.Context(), &proto.StatusRequest{ShouldRunProbes: true})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get status: %v\", status.Convert(err).Message())\n\t}\n\n\tstateWasDown := stat.Status != string(internal.StatusConnected) && stat.Status != string(internal.StatusConnecting)\n\n\tinitialLogLevel, err := client.GetLogLevel(cmd.Context(), &proto.GetLogLevelRequest{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get log level: %v\", status.Convert(err).Message())\n\t}\n\n\tif stateWasDown {\n\t\tif _, err := client.Up(cmd.Context(), &proto.UpRequest{}); err != nil {\n\t\t\tcmd.PrintErrf(\"Failed to bring service up: %v\\n\", status.Convert(err).Message())\n\t\t} else {\n\t\t\tcmd.Println(\"netbird up\")\n\t\t\ttime.Sleep(time.Second * 10)\n\t\t}\n\t}\n\n\tinitialLevelTrace := initialLogLevel.GetLevel() >= proto.LogLevel_TRACE\n\tif !initialLevelTrace {\n\t\t_, err = client.SetLogLevel(cmd.Context(), &proto.SetLogLevelRequest{\n\t\t\tLevel: proto.LogLevel_TRACE,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set log level to TRACE: %v\", status.Convert(err).Message())","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/debug.go#L246-L282","documentation":"Raised by runForDuration (`netbird debug for <duration>`) when client.GetLogLevel fails after Status already succeeded. The command reads the daemon's current log level so it can force TRACE and later restore the original value. The gRPC status message is surfaced verbatim.","triggerScenarios":"The daemon binary predates the GetLogLevel RPC and returns Unimplemented; the daemon restarts or shuts down between the Status and GetLogLevel calls; the context is canceled mid-sequence; the daemon is in a half-initialized state where the handler is not yet registered.","commonSituations":"CLI/daemon version skew after a partial upgrade (new CLI package, old service still running); running a built-from-source CLI against a released daemon; the service being restarted by a supervisor mid-command.","solutions":["Compare versions: `netbird version` for the CLI versus the daemon version shown by `netbird status`; upgrade whichever is older so both come from the same release","Restart the netbird service and re-run the debug command","If versions match and it persists, check the daemon log at the timestamp of the failure for the rejected RPC"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# ensure daemon version supports the log-level RPCs before running the command\nnetbird status | grep -q 'Daemon version' && netbird version  # compare the two; upgrade if the daemon is older","typeGuard":null,"tryCatchPattern":"resp, err := client.GetLogLevel(ctx, &proto.GetLogLevelRequest{})\nif err != nil {\n\tswitch status.Code(err) {\n\tcase codes.Unimplemented:\n\t\t// version skew: daemon predates this RPC; upgrade the service\n\t\treturn fmt.Errorf(\"daemon too old for GetLogLevel: upgrade the netbird service: %v\", err)\n\tcase codes.Unavailable, codes.Canceled:\n\t\t// daemon down or command interrupted; restart and retry once\n\t\treturn fmt.Errorf(\"daemon unavailable, restart it and retry: %w\", err)\n\tdefault:\n\t\treturn err\n\t}\n}","preventionTips":["Upgrade the netbird service whenever you upgrade the CLI so daemon RPCs match the CLI's calls","Restart the daemon before long debug sessions to avoid mid-command restarts","Treat Unimplemented from a daemon RPC as a version signal first, not a bug"],"tags":["grpc","version-mismatch","daemon","netbird-cli","log-level"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}