{"record":{"id":"75f2f4e4336db5d0","repo":"docker/compose","slug":"wait-timeout-must-be-a-non-negative-integer","errorCode":null,"errorMessage":"--wait-timeout must be a non-negative integer","messagePattern":"--wait-timeout must be a non-negative integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/up.go","lineNumber":192,"sourceCode":"\tflags.IntVar(&up.waitTimeout, \"wait-timeout\", 0, \"Maximum duration in seconds to wait for the project to be running|healthy\")\n\tflags.BoolVarP(&up.watch, \"watch\", \"w\", false, \"Watch source code and rebuild/refresh containers when files are updated.\")\n\tflags.BoolVar(&up.navigationMenu, \"menu\", false, \"Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var.\")\n\tflags.BoolVarP(&create.AssumeYes, \"yes\", \"y\", false, `Assume \"yes\" as answer to all prompts and run non-interactively`)\n\tflags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {\n\t\t// assumeYes was introduced by mistake as `--y`\n\t\tif name == \"y\" {\n\t\t\tlogrus.Warn(\"--y is deprecated, please use --yes instead\")\n\t\t\tname = \"yes\"\n\t\t}\n\t\treturn pflag.NormalizedName(name)\n\t})\n\treturn upCmd\n}\n\n//nolint:gocyclo\nfunc validateFlags(up *upOptions, create *createOptions) error {\n\tif up.waitTimeout < 0 {\n\t\treturn fmt.Errorf(\"--wait-timeout must be a non-negative integer\")\n\t}\n\tif up.exitCodeFrom != \"\" && !up.cascadeFail {\n\t\tup.cascadeStop = true\n\t}\n\tif up.cascadeStop && up.cascadeFail {\n\t\treturn fmt.Errorf(\"--abort-on-container-failure cannot be combined with --abort-on-container-exit\")\n\t}\n\tif up.wait {\n\t\tif up.attachDependencies || up.cascadeStop || len(up.attach) > 0 {\n\t\t\treturn fmt.Errorf(\"--wait cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies\")\n\t\t}\n\t\tup.Detach = true\n\t}\n\tif create.Build && create.noBuild {\n\t\treturn fmt.Errorf(\"--build and --no-build are incompatible\")\n\t}\n\tif up.Detach && (up.attachDependencies || up.cascadeStop || up.cascadeFail || len(up.attach) > 0 || up.watch) {\n\t\tif up.wait {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/up.go#L174-L210","documentation":"Returned by validateFlags during `docker compose up` PreRunE when the --wait-timeout flag is negative. The flag is declared as an integer, so any value parses, but the validation function rejects values below zero because a timeout cannot be negative. This runs before any docker interaction, so it fails instantly at CLI-argument level.","triggerScenarios":"Passing `docker compose up --wait-timeout -1` (or any negative int); scripts computing the timeout arithmetically and passing a negative result when a base value is smaller than a subtraction; a stray '-' parsed as a value.","commonSituations":"CI scripts deriving --wait-timeout from a deadline calculation that can go negative (e.g. `END - NOW`); typos like `--wait-timeout -=1`; negative values used intentionally to mean 'no timeout' — not supported here.","solutions":["Pass zero or a positive integer: `docker compose up --wait --wait-timeout 60` (0 means no timeout).","Fix the script computing the value: clamp with something like `MAX(0, computed)`.","If you intended 'wait forever', omit --wait-timeout or pass 0."],"exampleFix":"# before\nTIMEOUT=$((END_TS - $(date +%s)))   # can go negative\ndocker compose up --wait --wait-timeout $TIMEOUT\n\n# after\nTIMEOUT=$((END_TS - $(date +%s))); (( TIMEOUT < 0 )) && TIMEOUT=0\ndocker compose up --wait --wait-timeout $TIMEOUT","handlingStrategy":"validation","validationCode":"TIMEOUT=$(( ${WAIT_TIMEOUT:-60} )); (( TIMEOUT < 0 )) && TIMEOUT=0\ndocker compose up --wait --wait-timeout \"$TIMEOUT\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed timeouts to >= 0 at the source.","Use 0 to mean 'no timeout' rather than negatives.","Unit-test deadline arithmetic in deploy scripts."],"tags":["cli","up","flags","validation","timeout","compose"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}