{"record":{"id":"fd7f7409cd48bcf5","repo":"hashicorp/nomad","slug":"rcp-keep-alive-interval-must-be-greater-than-zero","errorCode":null,"errorMessage":"rcp.keep_alive_interval must be greater than zero","messagePattern":"rcp\\.keep_alive_interval must be greater than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/config.go","lineNumber":962,"sourceCode":"\tif rpc.StreamCloseTimeout > 0 {\n\t\tresult.StreamCloseTimeout = rpc.StreamCloseTimeout\n\t}\n\tif rpc.DialTimeoutHCL != \"\" {\n\t\tresult.DialTimeoutHCL = rpc.DialTimeoutHCL\n\t}\n\tif rpc.DialTimeout > 0 {\n\t\tresult.DialTimeout = rpc.DialTimeout\n\t}\n\treturn &result\n}\n\nfunc (r *RPCConfig) Validate() error {\n\tif r != nil {\n\t\tif r.AcceptBacklog < 0 {\n\t\t\treturn errors.New(\"rcp.accept_backlog interval must be greater than zero\")\n\t\t}\n\t\tif r.KeepAliveInterval < 0 {\n\t\t\treturn errors.New(\"rcp.keep_alive_interval must be greater than zero\")\n\t\t}\n\t\tif r.ConnectionWriteTimeout < 0 {\n\t\t\treturn errors.New(\"rcp.connection_write_timeout must be greater than zero\")\n\t\t}\n\t\tif r.StreamCloseTimeout < 0 {\n\t\t\treturn errors.New(\"rcp.stream_close_timeout must be greater than zero\")\n\t\t}\n\t\tif r.StreamOpenTimeout < 0 {\n\t\t\treturn errors.New(\"rcp.stream_open_timeout must be greater than zero\")\n\t\t}\n\t\tif r.DialTimeout < 0 {\n\t\t\treturn errors.New(\"rpc.dial_timeout must be greater than or equal to zero\")\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":944,"sourceCodeEnd":980,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/config.go#L944-L980","documentation":"Returned by RPCConfig.Validate() in command/agent/config.go when rpc.keep_alive_interval is set to a negative value. It fires at agent startup before the RPC layer is initialized. The 'rcp.' prefix in the message is a long-standing typo for 'rpc.'; only negative values are rejected (zero passes).","triggerScenarios":"Configuring `rpc { keep_alive_interval = -5s }` in the agent config or supplying a negative duration through config parsing into RPCConfig.KeepAliveInterval, then starting the agent.","commonSituations":"Typo'd durations in HCL/JSON agent config; environment-driven config templating producing negative durations; users attempting to disable keep-alives with a negative value instead of omitting the field.","solutions":["Set rpc.keep_alive_interval to zero or a positive duration (e.g. \"30s\")","Omit the field entirely to use the default keep-alive interval","Fix any config template logic that could emit a negative duration"],"exampleFix":"// before\nrpc { keep_alive_interval = -30s }\n// after\nrpc { keep_alive_interval = 30s }","handlingStrategy":"validation","validationCode":"if cfg.RPC != nil && cfg.RPC.KeepAliveInterval < 0 {\n\treturn fmt.Errorf(\"rpc.keep_alive_interval must be >= 0\")\n}","typeGuard":"func validKeepAlive(r *RPCConfig) bool {\n\treturn r == nil || r.KeepAliveInterval >= 0\n}","tryCatchPattern":"if err := rpcCfg.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"keep_alive_interval\") {\n\t\trpcCfg.KeepAliveInterval = 30 * time.Second\n\t}\n\treturn err\n}","preventionTips":["To disable keep-alives, omit the field rather than setting a negative duration","Validate rendered configs in CI before shipping them to agents","Use named duration constants in templates to avoid sign errors"],"tags":["config","validation","nomad-agent","rpc","keepalive"],"backgroundTag":"invalid-agent-config-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}