phacility/phabricator · error · Exception

Error while reading "%s": %s

Error message

Error while reading "%s": %s

What it means

ConduitParameterType is the base class for all typed Conduit parameters (list<int>, map, string, ...). When a subclass fails to read a parameter because the supplied value has the wrong shape or contents, it calls raiseValidationException(), which throws with 'Error while reading "<key>": <detail>'. The key names the parameter path and the detail explains the expected format.

Source

Thrown at src/applications/conduit/parametertype/ConduitParameterType.php:67

  final public function getTypeName() {
    return $this->getParameterTypeName();
  }


  final public function getFormatDescriptions() {
    return $this->getParameterFormatDescriptions();
  }


  final public function getExamples() {
    return $this->getParameterExamples();
  }

  protected function raiseValidationException(array $request, $key, $message) {
    // TODO: Specialize this so we can give users more tailored messages from
    // Conduit.
    throw new Exception(
      pht(
        'Error while reading "%s": %s',
        $key,
        $message));
  }


  final public static function getAllTypes() {
    return id(new PhutilClassMapQuery())
      ->setAncestorClass(__CLASS__)
      ->setUniqueMethod('getTypeName')
      ->setSortMethod('getTypeName')
      ->execute();
  }


  protected function getParameterExists(array $request, $key) {
    return array_key_exists($key, $request);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Read the method's parameter documentation on its /conduit/ console page and match the container type exactly (array vs string vs map).
  2. Fix the offending key named in the message, e.g. wrap comma-separated values into a JSON array.
  3. Validate your payload against the method's documented format with a JSON schema check before sending.

Example fix

// before
{"constraints": {"ids": "1,2,3"}}
// after
{"constraints": {"ids": [1, 2, 3]}}
Defensive patterns

Strategy: type-guard

Type guard

// PHP: assert container types match the method's documented parameters.
function assert_list_param(array $params, $key) {
  if (!isset($params[$key]) || !is_array($params[$key])) {
    throw new InvalidArgumentException(sprintf(
      'Parameter "%s" must be a JSON list, got %s.',
      $key,
      gettype($params[$key] ?? null)
    ));
  }
  if ($params[$key] !== array_values($params[$key])) {
    throw new InvalidArgumentException($key.' must be a list, not a map.');
  }
}

Try / catch

// From an HTTP/arc client: inspect the error_code in the response payload.
if ($response['error_code'] !== null) {
  // 'Error while reading "<key>": ...' names the exact offending parameter; fix and resend.
}

Prevention

When it happens

Trigger: Passing "ids": "1,2,3" (string) where the method declares a list (e.g. *.search constraints like phids/ids must be JSON arrays); passing an object where a list is expected; malformed inner values inside a container parameter.

Common situations: Hand-built parameter dictionaries against strongly typed *.search methods; scripts migrated from older loosely typed methods that accepted strings where new versions demand real JSON containers.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/9d09866e3f54c26f. Report an issue: GitHub.