{"record":{"id":"162d2ab223609515","repo":"phacility/phabricator","slug":"specify-a-source-with-s","errorCode":null,"errorMessage":"Specify a source with %s.","messagePattern":"Specify a source with (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/nuance/management/NuanceManagementWorkflow.php","lineNumber":9,"sourceCode":"<?php\n\nabstract class NuanceManagementWorkflow\n  extends PhabricatorManagementWorkflow {\n\n  protected function loadSource(PhutilArgumentParser $argv, $key) {\n    $source = $argv->getArg($key);\n    if (!strlen($source)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify a source with %s.',\n          '--'.$key));\n    }\n\n    $query = id(new NuanceSourceQuery())\n      ->setViewer($this->getViewer())\n      ->setRaisePolicyExceptions(true);\n\n    $type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;\n\n    if (ctype_digit($source)) {\n      $kind = 'id';\n      $query->withIDs(array($source));\n    } else if (phid_get_type($source) !== $type_unknown) {\n      $kind = 'phid';\n      $query->withPHIDs($source);\n    } else {","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/management/NuanceManagementWorkflow.php#L1-L27","documentation":"The most basic guard in NuanceManagementWorkflow::loadSource(): every source-driven nuance management command requires --source, and the helper throws PhutilArgumentUsageException when the argument value has zero length. It exists so commands fail fast with a clear message instead of querying with an empty selector.","triggerScenarios":"Invoking any subclass workflow that calls loadSource($args, 'source') (e.g. bin/nuance import) without --source, or with an empty value ('--source \"\"'). strlen($source) == 0 triggers the throw before any query runs.","commonSituations":"New operators unaware the flag is mandatory; scripts where a $SOURCE shell variable is unset/empty and the command interpolates to '--source '; CI pipelines reusing a command template across projects where only some set the variable.","solutions":["Pass a source selector: --source <ID> (numeric), --source <PHID> (PHID-NUAN-...), or --source <name>.","In scripts, guard before invoking: fail the script when the variable is empty rather than calling bin/nuance with a blank flag.","List valid sources first (bin/nuance ... or the Nuance web UI) to get an exact ID/name."],"exampleFix":"# before:\n# bin/nuance import --source \"\"\n# -> err: 'Specify a source with --source.'\n\n# after:\n# bin/nuance import --source 12\n\n# script guard:\n[ -z \"$SOURCE\" ] && { echo 'SOURCE not set' >&2; exit 2; }\nbin/nuance import --source \"$SOURCE\"","handlingStrategy":"validation","validationCode":"// Script-side guard before building the command:\nif (!strlen(trim((string)$source_selector))) {\n  throw new Exception('nuance commands require --source <id|phid|name>');\n}\n$cmd = sprintf('bin/nuance import --source %s', escapeshellarg($source_selector));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --source as mandatory in every wrapper script and validate it before exec.","Fail fast with a clear message when the selector variable is unset instead of interpolating an empty string.","Keep a canonical list of source IDs/PHIDs per environment for scripts to draw from."],"tags":["nuance","cli","missing-argument","usage-error"],"backgroundTag":"missing-required-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}