{"record":{"id":"0ca3bbaede1e4bdd","repo":"googleapis/mcp-toolbox","slug":"invalid-value-for-maxdelay-w","errorCode":null,"errorMessage":"invalid value for maxDelay: %w","messagePattern":"invalid value for maxDelay: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/alloydb/alloydbwaitforoperation/alloydbwaitforoperation.go","lineNumber":142,"sourceCode":"\tvar delay time.Duration\n\tif cfg.Delay == \"\" {\n\t\tdelay = 3 * time.Second\n\t} else {\n\t\tvar err error\n\t\tdelay, err = time.ParseDuration(cfg.Delay)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid value for delay: %w\", err)\n\t\t}\n\t}\n\n\tvar maxDelay time.Duration\n\tif cfg.MaxDelay == \"\" {\n\t\tmaxDelay = 4 * time.Minute\n\t} else {\n\t\tvar err error\n\t\tmaxDelay, err = time.ParseDuration(cfg.MaxDelay)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid value for maxDelay: %w\", err)\n\t\t}\n\t}\n\n\tmultiplier := cfg.Multiplier\n\tif multiplier == 0 {\n\t\tmultiplier = 2.0\n\t}\n\n\tmaxRetries := cfg.MaxRetries\n\tif maxRetries == 0 {\n\t\tmaxRetries = 10\n\t}\n\n\tparams := buildParams(\"\")\n\treturn Tool{\n\t\tBaseTool: tools.NewBaseTool(\n\t\t\tcfg,\n\t\t\ttools.GetAnnotationsOrDefault(cfg.Annotations, tools.NewReadOnlyAnnotations),","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/alloydb/alloydbwaitforoperation/alloydbwaitforoperation.go#L124-L160","documentation":"Initialize() parses the tool's optional maxDelay config field with time.ParseDuration. When the string cannot be parsed as a Go duration (e.g. \"5\", \"5m30\", \"five minutes\"), the parse error is wrapped and initialization of the alloydb-wait-for-operation tool fails immediately at config-load time.","triggerScenarios":"Calling Initialize() on an alloydb-wait-for-operation Config whose MaxDelay is non-empty and not a valid Go duration string (valid: \"30s\", \"5m\", \"1h\", \"500ms\"; invalid: \"5\", \"5 minutes\", \"\", missing unit).","commonSituations":"YAML configs where maxDelay is written as a bare number (\"maxDelay: 300\") instead of a duration string, typos like \"5mintues\", or quoting/whitespace issues in the YAML that leave stray characters in the value.","solutions":["Fix maxDelay in the tool config to a valid Go duration string with a unit, e.g. \"5m\" or \"4m\".","Remove the maxDelay field entirely to use the default of 4 minutes.","Validate the value locally with time.ParseDuration before writing it into the config to get a clearer message."],"exampleFix":"// before (invalid)\nmaxDelay: 300\n// after\nmaxDelay: 300s","handlingStrategy":"validation","validationCode":"if cfg.MaxDelay != \"\" {\n    if _, err := time.ParseDuration(cfg.MaxDelay); err != nil {\n        return fmt.Errorf(\"maxDelay %q is not a valid duration: %w\", cfg.MaxDelay, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"_, err := toolConfig.Initialize(ctx)\nif err != nil {\n    var cfgErr error\n    if errors.As(err, &cfgErr) && strings.Contains(err.Error(), \"invalid value for maxDelay\") {\n        // fall back to default (omit maxDelay) and re-init\n    }\n}","preventionTips":["Always include a unit suffix in duration values: 30s, 5m, 1h.","Never write maxDelay as a bare number in YAML; quote it as a string.","Run config validation locally (time.ParseDuration) before deploying."],"tags":["configuration","duration-parsing","golang","alloydb"],"backgroundTag":"invalid-duration-format","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}