{"record":{"id":"c1031849ff47f0c7","repo":"multica-ai/multica","slug":"download-timeout-must-be-greater-than-zero","errorCode":null,"errorMessage":"download timeout must be greater than zero","messagePattern":"download timeout must be greater than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_update.go","lineNumber":28,"sourceCode":"\n\t\"github.com/multica-ai/multica/server/internal/cli\"\n)\n\nvar updateDownloadTimeout time.Duration = cli.DefaultUpdateDownloadTimeout\n\nvar updateCmd = &cobra.Command{\n\tUse:   \"update\",\n\tShort: \"Update multica to the latest version\",\n\tRunE:  runUpdate,\n}\n\nfunc init() {\n\tupdateCmd.Flags().DurationVar(&updateDownloadTimeout, \"download-timeout\", cli.DefaultUpdateDownloadTimeout, \"Maximum time to wait for the release archive download\")\n}\n\nfunc runUpdate(_ *cobra.Command, _ []string) error {\n\tif updateDownloadTimeout <= 0 {\n\t\treturn fmt.Errorf(\"download timeout must be greater than zero\")\n\t}\n\n\tfmt.Fprintf(os.Stderr, \"Current version: %s (commit: %s, built: %s)\\n\", version, commit, date)\n\n\t// Check latest version from GitHub.\n\tlatest, err := cli.FetchLatestRelease()\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Warning: could not check latest version: %v\\n\", err)\n\t} else {\n\t\tlatestVer := strings.TrimPrefix(latest.TagName, \"v\")\n\t\tcurrentVer := strings.TrimPrefix(version, \"v\")\n\t\tif currentVer == latestVer {\n\t\t\tfmt.Fprintln(os.Stderr, \"Already up to date.\")\n\t\t\treturn nil\n\t\t}\n\t\tfmt.Fprintf(os.Stderr, \"Latest version:  %s\\n\\n\", latest.TagName)\n\t}\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_update.go#L10-L46","documentation":"Thrown by `multica update` when the --download-timeout flag is set to zero or a negative duration. The value defaults to cli.DefaultUpdateDownloadTimeout, so this only fires when the user explicitly overrides it. The guard exists because a non-positive timeout would make the HTTP client for the release-archive download fail immediately or hang forever.","triggerScenarios":"Running `multica update --download-timeout 0` or `--download-timeout -5s`. The check `updateDownloadTimeout <= 0` in runUpdate fires before any network call.","commonSituations":"Scripts that set the timeout from an unset/empty environment variable (Go parses \"\" as 0), or users copying a duration flag from another tool and dropping the unit suffix.","solutions":["Pass a positive Go duration with a unit, e.g. `multica update --download-timeout 120s` (or 2m).","If the value comes from a script/env var, verify it is non-empty and parses to a positive duration before invoking the command.","Omit the flag entirely to use the sane default (cli.DefaultUpdateDownloadTimeout)."],"exampleFix":"# before\nmultica update --download-timeout 0\n\n# after\nmultica update --download-timeout 120s","handlingStrategy":"validation","validationCode":"# validate before invoking\nTIMEOUT=\"${TIMEOUT:-120s}\"\nif [ -z \"$TIMEOUT\" ] || ! grep -qE '^[0-9]+(ns|us|µs|ms|s|m|h)([0-9]+(ns|us|µs|ms|s|m|h))*$' \"$TIMEOUT\"; then\n  echo \"invalid timeout: $TIMEOUT\" >&2; exit 1\nfi\nmultica update --download-timeout \"$TIMEOUT\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default --download-timeout from a non-empty env var: TIMEOUT=\"${TIMEOUT:-120s}\".","Always include a Go duration unit (s, m, h); bare numbers are invalid.","Omit the flag unless you genuinely need a different timeout."],"tags":["cli","validation","flag","update"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}