phacility/phabricator · error · Exception

Minimum page size for API searches is 1, but this call speci

Error message

Minimum page size for API searches is 1, but this call specified %s.

What it means

The lower-bound twin of the page-size check in setPagerSizeForConduit(): a Conduit search 'limit' below 1 (0 or negative) is rejected because a page must yield at least one result. Note the asymmetry - limit === null means 'use default', but an explicit out-of-range number is an error, not silently corrected.

Source

Thrown at src/applications/search/engine/PhabricatorApplicationSearchEngine.php:1389

    if ($limit === null) {
      if ($pager->getPageSize() >= 0xFFFF) {
        return;
      } else {
        $limit = 100;
      }
    }

    if ($limit > 100) {
      throw new Exception(
        pht(
          'Maximum page size for Conduit API method calls is 100, but '.
          'this call specified %s.',
          $limit));
    }

    if ($limit < 1) {
      throw new Exception(
        pht(
          'Minimum page size for API searches is 1, but this call '.
          'specified %s.',
          $limit));
    }

    $pager->setPageSize($limit);
  }

  private function setPagerOffsetsForConduit(
    $pager,
    ConduitAPIRequest $request) {
    $before_id = $request->getValue('before');
    if ($before_id !== null) {
      $pager->setBeforeID($before_id);
    }

    $after_id = $request->getValue('after');

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Use limit between 1 and 100; omit 'limit' entirely when the default is fine.
  2. Replace 0-unlimited sentinels: map 0/absent to null before the call, or just always request a fixed page size and rely on cursors.
  3. Fix countdown pagination: stop the loop when the computed next-page size < 1 instead of issuing the request.
  4. If you only need a count, look for a count-capable result mode instead of an empty page.

Example fix

// before: 0 used as 'default' sentinel
$params['limit'] = $user_limit ?: 0;

// after: omit the key to get the default
if ($user_limit) { $params['limit'] = min(100, max(1, $user_limit)); }
Defensive patterns

Strategy: validation

Validate before calling

if (isset($params['limit'])) { $params['limit'] = max(1, min(100, (int)$params['limit'])); }

Type guard

function isPageableLimit($n) { return $n === null || (is_int($n) && $n >= 1 && $n <= 100); }

Try / catch

try {
  $r = $client->call('maniphest.search', $params);
} catch (Exception $ex) {
  if (strpos($ex->getMessage(), 'Minimum page size') !== false) {
    unset($params['limit']);
    $r = $client->call('maniphest.search', $params);
  }
}

Prevention

When it happens

Trigger: Calling `<app>.search` with `"limit": 0` (often a script default meaning 'no limit' or 'count only') or a negative value from arithmetic (e.g. $limit = $total - $fetched going negative on the final page).

Common situations: Scripts using 0 as a sentinel for unlimited (common convention elsewhere, invalid here); countdown loops computing the last page size as remainder - 1; configuration values defaulting to 0/null conflated and passed through as 0.

Related errors


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