phacility/phabricator · error · Exception
Too many relationships (%s, of type "%s").
Error message
Too many relationships (%s, of type "%s").
What it means
PhabricatorSearchRelationshipController processes the POST from the 'add relationships' dialog (subscribers, projects, depends on, etc.). The UI normally caps selection in Javascript; server-side it re-checks count($phids) against the relationship's getMaximumSelectionSize() (e.g. 1 for 'maniphest.subscribers'? actually 1 for owner-type relationships) and throws this raw Exception as a sanity check when the POST carries more PHIDs than allowed. It is intentionally not user-friendly because a legit client never triggers it.
Source
Thrown at src/applications/search/controller/PhabricatorSearchRelationshipController.php:52
$all_phids[] = $src_phid;
$handles = $viewer->loadHandles($all_phids);
$src_handle = $handles[$src_phid];
$done_uri = $src_handle->getURI();
$initial_phids = $dst_phids;
$maximum = $relationship->getMaximumSelectionSize();
if ($request->isFormPost()) {
$phids = explode(';', $request->getStr('phids'));
$phids = array_filter($phids);
$phids = array_values($phids);
// The UI normally enforces this with Javascript, so this is just a
// sanity check and does not need to be particularly user-friendly.
if ($maximum && (count($phids) > $maximum)) {
throw new Exception(
pht(
'Too many relationships (%s, of type "%s").',
phutil_count($phids),
$relationship->getRelationshipConstant()));
}
$initial_phids = $request->getStrList('initialPHIDs');
// Apply the changes as adds and removes relative to the original state
// of the object when the dialog was rendered so that two users adding
// relationships at the same time don't race and overwrite one another.
$add_phids = array_diff($phids, $initial_phids);
$rem_phids = array_diff($initial_phids, $phids);
$all_phids = array_merge($add_phids, $rem_phids);
$capabilities = $relationship->getRequiredRelationshipCapabilities();
if ($all_phids) {View on GitHub (pinned to 5720a38cfe)
Solutions
- If this fires in normal use, report it as a Phabricator UI bug - the Javascript tokenizer should have limited selection before POST.
- If you drive this endpoint programmatically, slice the PHID list to the relationship maximum before POSTing (query the relationship config for the cap).
- Refresh the dialog (reload the page) so the current, cap-enforcing Javascript is loaded instead of a stale cached one.
- Split bulk additions into multiple requests that each respect the cap.
Example fix
// before
$phids = explode(';', $request->getStr('phids'));
// after (client side: cap before submit)
var phids = tokens.map(t => t.getPHID());
if (phids.length > config.getMaximumSelectionSize()) {
phids = phids.slice(0, config.getMaximumSelectionSize());
} Defensive patterns
Strategy: validation
Validate before calling
// Client side: cap selection before POST
var max = config.maximumSelectionSize;
if (max && tokens.length > max) { tokens = tokens.slice(0, max); }
// API side: know the cap before building the request
$max = $relationship->getMaximumSelectionSize();
$phids = $max ? array_slice($phids, 0, $max) : $phids; Try / catch
// Server code already wraps this into a dialog; callers should not hit it. // If scripting the endpoint, validate first as above and treat any Exception // here as a bug report, not a recoverable condition.
Prevention
- Always drive relationship dialogs through the shipped Javascript tokenizer
- Re-check caps after Phabricator upgrades change relationship limits
- Never craft raw POSTs to /search/relationship/ with unbounded phids lists
When it happens
Trigger: POSTing to /search/relationship/... with a 'phids' semicolon-separated string containing more entries than the relationship allows - e.g. assigning two owners to a task via a crafted request, or a stale browser tab using an old dialog that did not enforce the cap.
Common situations: Custom scripts or API clients driving the relationship dialog endpoint directly with unclipped lists; browser extension or userscript modifying the tokenizer; multiple-SELECT UI bug after an upgrade that removed the JS cap; race where a user pastes a large list into a single-select dialog.
Related errors
- You can not create a relationship to object "%s" because obj
- You can not create a relationship (of type "%s") to object "
- Request includes restricted parameter "%s", but this control
- Unrecognized verb: %s
- Invalid revision ID "%s".
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/7d9e4e1ed1890bba.
Report an issue: GitHub.