{"record":{"id":"355832ae384a6297","repo":"argoproj/argo-workflows","slug":"maxretries-cannot-be-less-than-0","errorCode":null,"errorMessage":"maxRetries cannot be less than 0","messagePattern":"maxRetries cannot be less than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/sqldb/session.go","lineNumber":62,"sourceCode":"\n\tinsideTransaction bool\n}\n\n// SessionProxyConfig contains configuration for creating a SessionProxy\ntype SessionProxyConfig struct {\n\tKubectlConfig kubernetes.Interface\n\tNamespace     string\n\tDBConfig      config.DBConfig\n\tUsername      string\n\tPassword      string\n\tMaxRetries    int\n\tBaseDelay     time.Duration\n\tMaxDelay      time.Duration\n}\n\nfunc validateProxyParams(proxy *SessionProxy) error {\n\tif proxy.maxRetries < 0 {\n\t\treturn fmt.Errorf(\"maxRetries cannot be less than 0\")\n\t}\n\tif proxy.baseDelay < 0 {\n\t\treturn fmt.Errorf(\"baseDelay cannot be less than 0\")\n\t}\n\tif proxy.maxDelay < 0 {\n\t\treturn fmt.Errorf(\"maxDelay cannot be less than 0\")\n\t}\n\tif proxy.retryMultiple < 0 {\n\t\treturn fmt.Errorf(\"retryMultiple cannot be less than 0\")\n\t}\n\treturn nil\n}\n\n// NewSessionProxy creates a new SessionProxy with the given configuration\nfunc NewSessionProxy(ctx context.Context, config SessionProxyConfig) (*SessionProxy, error) {\n\tdbType := dbTypeFromConfig(&config.DBConfig)\n\tproxy := &SessionProxy{\n\t\tkubectlConfig: config.KubectlConfig,","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/util/sqldb/session.go#L44-L80","documentation":"validateProxyParams sanity-checks SessionProxy retry settings before a session proxy is created. maxRetries counts reconnection attempts, so a negative count is meaningless; the function rejects it with this error. It is a pure input-validation error raised from NewSessionProxy.","triggerScenarios":"Calling NewSessionProxy with SessionProxyConfig.MaxRetries < 0, or with DBConfig.DBReconnectConfig.MaxRetries < 0 (reconnect config overrides MaxRetries before validation).","commonSituations":"A config file (workflow-controller config persistence/dbReconnectConfig) where maxRetries is negative due to a typo or a bad template/default value; programmatically computing retries with an underflow (e.g. len(list) - n where n > len).","solutions":["Set MaxRetries (or DBReconnectConfig.MaxRetries) to a non-negative value — 0 is allowed and falls back to the default of 5.","If the value comes from a config file, fix the negative number under dbReconnectConfig.maxRetries.","If computed programmatically, clamp before calling: if v < 0 { v = 0 }.","Note the exact message tells you which field is wrong; check only maxRetries for this variant."],"exampleFix":"// before\nSessionProxyConfig{MaxRetries: -1}\n// after\nSessionProxyConfig{MaxRetries: 5} // 0 => default of 5","handlingStrategy":"validation","validationCode":"if cfg.MaxRetries < 0 {\n    return fmt.Errorf(\"MaxRetries must be >= 0, got %d\", cfg.MaxRetries)\n}","typeGuard":null,"tryCatchPattern":"if err := NewSessionProxy(ctx, cfg); err != nil {\n    if strings.Contains(err.Error(), \"maxRetries cannot be less than 0\") {\n        cfg.MaxRetries = 0 // fall back to default\n        return NewSessionProxy(ctx, cfg)\n    }\n    return err\n}","preventionTips":["Validate controller config YAML at load time with non-negative bounds.","Use uint or a clamped setter for retry counts.","Review config-generation templates for sign errors.","Add a CI check that renders and validates the controller ConfigMap."],"tags":["validation","database","configuration"],"backgroundTag":"invalid-argument-value","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}