phacility/phabricator · error · Exception
Argument "%s" (in position "%s") to function "%s" is invalid
Error message
Argument "%s" (in position "%s") to function "%s" is invalid: %s
What it means
This is the parser's wrapper error: when a raw argument value is rejected by PhabricatorChartFunctionArgument::newValue() (bad type, unknown fact key, malformed nested function, etc.), parseArguments() catches the Exception and rethrows one that prefixes the argument name, 1-based position, and full function signature to the original message.
Source
Thrown at src/applications/fact/chart/PhabricatorChartFunctionArgumentParser.php:165
$want_count,
$have_count));
}
$raw_argument = array_shift($this->unconsumedArguments);
$this->argumentPosition++;
$is_repeatable = $argument->getRepeatable();
// If this argument is repeatable and we have more arguments, add it
// back to the end of the list so we can continue parsing.
if ($is_repeatable && $this->unconsumedArguments) {
$this->unparsedArguments[] = $argument;
}
try {
$value = $argument->newValue($raw_argument);
} catch (Exception $ex) {
throw new Exception(
pht(
'Argument "%s" (in position "%s") to function "%s" is '.
'invalid: %s',
$name,
$this->argumentPosition,
$this->getFunctionArgumentSignature(),
$ex->getMessage()));
}
if ($is_repeatable) {
if (!isset($this->argumentValues[$name])) {
$this->argumentValues[$name] = array();
}
$this->argumentValues[$name][] = $value;
} else {
$this->argumentValues[$name] = $value;
}
}View on GitHub (pinned to 5720a38cfe)
Solutions
- Read the tail of the message after 'is invalid:' — it is the exact underlying validation error (e.g. fact key or type problem).
- Fix that value for the named argument at the stated position.
- If building specs from user input, validate each argument against its expected type before chart construction.
- Wrap chart construction in try/catch to surface these errors to the UI instead of a hard failure.
Example fix
// before: raw user input fed straight into chart construction
$functions[] = array('fact', $request->getValue('factKey'));
// after: validate first, fail with a useful message
$fact_key = $request->getValue('factKey');
if (!is_string($fact_key) ||
!isset(PhabricatorFact::getAllFacts()[$fact_key])) {
return new Aphront404Response(); // or user-facing error
}
$functions[] = array('fact', $fact_key); Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate a fact argument before chart construction
$facts = PhabricatorFact::getAllFacts();
if (!isset($facts[$fact_key])) {
throw new Exception('Unknown fact key: '.$fact_key);
} Try / catch
try {
$function->setArguments($raw_arguments);
$parser->parseArguments();
} catch (Exception $ex) {
// message embeds argument name, position, signature, and cause
throw new PhutilProxyException('Invalid chart specification', $ex);
} Prevention
- Read the text after 'is invalid:' — it is the underlying cause.
- Validate each argument's type/registry membership before constructing chart functions.
- Convert these exceptions into user-facing form errors when specs come from request data.
When it happens
Trigger: Any of the per-argument validation failures (non-string fact key, unknown fact key, non-list function definition, non-natural list, empty list, non-string function name, unknown function name, non-number for 'number') occurring while PhabricatorChartFunctionArgumentParser::parseArguments() evaluates a chart function's arguments.
Common situations: Rendering charts built from stored or user-supplied dictionaries; chart specs authored in JSON/Conduit payloads; debugging — the suffix after 'invalid:' is the underlying cause and should be read first.
Related errors
- Value for "fact-key" argument must be a string, got %s.
- Value for "function" argument must be a function definition,
- Value for "function" argument must be a natural list, not a
- Value for "function" argument must be a list with a function
- Value for "function" argument must be a natural list beginni
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/7ca36e6d1a84ed10.
Report an issue: GitHub.