{"record":{"id":"0151890d3a0a480b","repo":"amir20/dozzle","slug":"failed-to-create-agent-server-w","errorCode":null,"errorMessage":"failed to create agent server: %w","messagePattern":"failed to create agent server: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/cli/agent_command.go","lineNumber":257,"sourceCode":"\t\tHostService:   agentHostService,\n\t\tLabels:        args.Filter,\n\t})\n\t// An agent is always an agent, whatever the hub in front of it is running as.\n\tcloudClient.SetDeployment(\"agent\", swarmClusterID)\n\tcloudClient.SetStreamLogsFunc(func() bool {\n\t\tcc := notificationHandler.CloudConfig()\n\t\treturn cc != nil && cc.StreamLogsEnabled()\n\t})\n\tnotificationHandler.onCloudSet = cloudClient.Notify\n\tgo cloudClient.Run(ctx)\n\tif apiKeyFunc() != \"\" {\n\t\tcloudClient.Notify()\n\t}\n\n\t// Create agent server using the same shared client service\n\tserver, err := agent.NewServer(clientService, certs, args.Version(), notificationHandler)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create agent server: %w\", err)\n\t}\n\tgo func() {\n\t\tlog.Info().Msgf(\"Dozzle agent version %s\", args.Version())\n\t\tlog.Info().Msgf(\"Agent listening on %s\", listener.Addr().String())\n\n\t\tif err := server.Serve(listener); err != nil {\n\t\t\tlog.Error().Err(err).Msg(\"failed to serve\")\n\t\t}\n\t}()\n\t<-ctx.Done()\n\tstop()\n\tlog.Info().Msg(\"Shutting down agent\")\n\tserver.Stop()\n\tlog.Debug().Str(\"file\", agentAddrFile).Msg(\"Removing agent address file\")\n\tos.Remove(agentAddrFile)\n\treturn nil\n}\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/cli/agent_command.go#L239-L275","documentation":"Returned by AgentCmd.Run when agent.NewServer fails to construct the gRPC agent server. The server wraps the shared client service, TLS certificates, and notification handler; failure usually indicates the supplied TLS credentials are invalid for gRPC use.","triggerScenarios":"certs parsed from ReadCertificates are structurally invalid for gRPC credentials (malformed cert/key pair); passing nil or mismatched certificate material to NewServer.","commonSituations":"Custom cert/key files that load as PEM but fail gRPC credential construction; certs regenerated for one component but not shared with the agent build; corrupted embedded FS in custom builds.","solutions":["Regenerate certificates with `make generate` so cert/key match and are valid.","Drop custom --cert-path/--key-path overrides to use the embedded certs.","Validate the PEM pair: `openssl x509 -in cert.pem -noout` and `openssl rsa -in key.pem -check`.","Confirm agent and main server use the same shared key/cert.","Update dozzle to the latest release."],"exampleFix":"// before\n--cert-path /etc/dozzle/cert.pem --key-path /etc/dozzle/mismatched.key\n// after\n--cert-path /etc/dozzle/cert.pem --key-path /etc/dozzle/key.pem  # matching pair\n// or regenerate:\nmake generate","handlingStrategy":"validation","validationCode":"openssl x509 -in cert.pem -noout && openssl rsa -in key.pem -check && diff <(openssl x509 -in cert.pem -noout -modulus) <(openssl rsa -in key.pem -noout -modulus) && echo 'cert/key pair OK'","typeGuard":null,"tryCatchPattern":"if err := agentCmd.Run(args, embeddedCerts); err != nil {\n  if strings.Contains(err.Error(), \"failed to create agent server\") {\n    log.Fatal().Err(err).Msg(\"invalid TLS material for gRPC server; regenerate certs\")\n  }\n}","preventionTips":["Regenerate certs with `make generate` when unsure","Keep one shared cert pair across agent and server","Validate cert/key modulus match before deploying","Avoid hand-edited or partially copied PEM files"],"tags":["grpc","tls","agent"],"backgroundTag":"invalid-constructor-argument","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"}