{"record":{"id":"cc1032b61ef6b544","repo":"amir20/dozzle","slug":"unknown-code-v-with-w","errorCode":null,"errorMessage":"unknown code: %v with %w","messagePattern":"unknown code: (.+?) with %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/client.go","lineNumber":131,"sourceCode":"\tif !ok {\n\t\treturn err\n\t}\n\n\tif status.Code() == codes.Unknown && status.Message() == \"EOF\" {\n\t\treturn fmt.Errorf(\"EOF error while converting gRPC to error: %w\", io.EOF)\n\t}\n\n\tswitch status.Code() {\n\tcase codes.Canceled:\n\t\treturn fmt.Errorf(\"canceled: %v with %w\", status.Message(), context.Canceled)\n\tcase codes.DeadlineExceeded:\n\t\treturn fmt.Errorf(\"deadline exceeded: %v with %w\", status.Message(), context.DeadlineExceeded)\n\tcase codes.Unknown:\n\t\treturn fmt.Errorf(\"unknown error: %v with %w\", status.Message(), err)\n\tcase codes.OK:\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown code: %v with %w\", status.Code(), err)\n\t}\n}\n\nfunc (c *Client) LogsBetweenDates(ctx context.Context, containerID string, since time.Time, until time.Time, std container.StdType) (<-chan *container.LogEvent, error) {\n\tstream, err := c.client.LogsBetweenDates(ctx, &pb.LogsBetweenDatesRequest{\n\t\tContainerId: containerID,\n\t\tSince:       timestamppb.New(since),\n\t\tUntil:       timestamppb.New(until),\n\t\tStreamTypes: int32(std),\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tevents := make(chan *container.LogEvent)\n\n\tgo func() {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/agent/client.go#L113-L149","documentation":"rpcErrToErr's default branch maps any unrecognized gRPC status code to \"unknown code: %v with %w\", wrapping the original error. It fires when the agent or an intermediary returns a code this client does not explicitly translate (e.g. Unavailable, ResourceExhausted, Internal, PermissionDenied).","triggerScenarios":"Any RPC to the agent returning a non-OK status code other than Canceled, DeadlineExceeded, Unknown, or OK: Unavailable during agent restart, ResourceExhausted on message-size limits, Internal from TLS/transport failures.","commonSituations":"Agent container restarting while server streams logs (Unavailable); huge log payloads exceeding the 10MB receive limit (ResourceExhausted); TLS cert mismatch causing Internal/Unavailable; firewall dropping the 7007 connection.","solutions":["Inspect the wrapped code (`status.Convert(err).Code()`) and handle common ones: retry with backoff on Unavailable, reduce request size on ResourceExhausted","Add restart/backoff logic keyed on codes.Unavailable, which usually means the agent is temporarily down","Align agent/server versions and regenerate shared certs (`make generate`) if TLS errors appear","Ensure port 7007 is reachable between hosts (firewall, Docker network)"],"exampleFix":"// before\nif err := <-errCh; err != nil { log.Error().Err(err).Msg(\"rpc failed\") }\n// after\nif err := <-errCh; err != nil {\n    if status, ok := status.FromError(errors.Unwrap(err)); ok && status.Code() == codes.Unavailable {\n        time.Sleep(2 * time.Second) // backoff and retry\n        return\n    }\n    log.Error().Err(err).Msg(\"rpc failed\")\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n    if st, ok := status.FromError(errors.Unwrap(err)); ok && st.Code() == codes.Unavailable {\n        time.Sleep(backoff); retry(); return\n    }\n    log.Error().Err(err).Msg(\"rpc failed\")\n}","preventionTips":["Implement exponential backoff on codes.Unavailable for agent restarts","Keep payload sizes under the 10MB receive limit; paginate large log fetches","Verify host networking (port 7007, firewalls) before rollout"],"tags":["go","grpc","network","agent"],"backgroundTag":"grpc-unavailable","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}