{"record":{"id":"6ebad4f9dadef5ea","repo":"phacility/phabricator","slug":"specify-a-positive-number-of-days-to-retain-data-f","errorCode":null,"errorMessage":"Specify a positive number of days to retain data for.","messagePattern":"Specify a positive number of days to retain data for\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementSetPolicyWorkflow.php","lineNumber":85,"sourceCode":"          '--days',\n          '--indefinite',\n          '--default'));\n    }\n\n    if ($count > 1) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Options \"%s\", \"%s\" and \"%s\" represent mutually exclusive ways '.\n          'to choose a policy. Specify only one.',\n          '--days',\n          '--indefinite',\n          '--default'));\n    }\n\n    if ($days !== null) {\n      $days = (int)$days;\n      if ($days < 1) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Specify a positive number of days to retain data for.'));\n      }\n    }\n\n    $collector_const = $collector->getCollectorConstant();\n    $value = PhabricatorEnv::getEnvConfig($config_key);\n\n    if ($days !== null) {\n      echo tsprintf(\n        \"%s\\n\",\n        pht(\n          'Setting retention policy for \"%s\" to %s day(s).',\n          $collector->getCollectorName(),\n          new PhutilNumber($days)));\n\n      $value[$collector_const] = phutil_units($days.' days in seconds');\n    } else if ($indefinite) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/daemon/garbagecollector/management/PhabricatorGarbageCollectorManagementSetPolicyWorkflow.php#L67-L103","documentation":"After accepting --days, the workflow casts the value to int and requires it to be at least 1; zero or negative values throw this usage exception. The guard prevents configuring a collector with a nonsensical retention window of zero or fewer days.","triggerScenarios":"bin/garbagecollector set-policy --collector <const> --days 0, a negative number, or a string that casts to <= 0.","commonSituations":"Automation computing a day count from a date delta that evaluates to 0; operators trying to express 'delete everything now' via --days 0 instead of running the collector.","solutions":["Use --days 1 or greater.","To purge immediately, run the collect workflow rather than setting a zero-day retention policy.","Check the arithmetic that produces the day count in scripts."],"exampleFix":"# before\nbin/garbagecollector set-policy --collector <collector> --days 0\n# after\nbin/garbagecollector set-policy --collector <collector> --days 1","handlingStrategy":"validation","validationCode":"if ($days !== null && (int)$days < 1) {\n  // reject before running: --days must be a positive integer\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed day counts to a minimum of 1 in automation.","Use the collect workflow to purge immediately instead of --days 0."],"tags":["phabricator","garbage-collector","cli","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}