phacility/phabricator · error · Exception
You can not create a relationship to object "%s" because obj
Error message
You can not create a relationship to object "%s" because objects can not be related to themselves.
What it means
The relationship controller forbids relating an object to itself: while looping over added PHIDs, any $add_phid equal to the source object's $src_phid triggers this Exception (caught and shown as an unrelatable-object dialog). Self-referential edges would create nonsense like 'task T depends on task T' and can loop graph algorithms, so they are rejected outright.
Source
Thrown at src/applications/search/controller/PhabricatorSearchRelationshipController.php:94
->execute();
$dst_objects = mpull($dst_objects, null, 'getPHID');
} else {
$dst_objects = array();
}
try {
foreach ($add_phids as $add_phid) {
$dst_object = idx($dst_objects, $add_phid);
if (!$dst_object) {
throw new Exception(
pht(
'You can not create a relationship to object "%s" because '.
'the object does not exist or could not be loaded.',
$add_phid));
}
if ($add_phid == $src_phid) {
throw new Exception(
pht(
'You can not create a relationship to object "%s" because '.
'objects can not be related to themselves.',
$add_phid));
}
if (!$relationship->canRelateObjects($object, $dst_object)) {
throw new Exception(
pht(
'You can not create a relationship (of type "%s") to object '.
'"%s" because it is not the right type of object for this '.
'relationship.',
$relationship->getRelationshipConstant(),
$add_phid));
}
}
} catch (Exception $ex) {
return $this->newUnrelatableObjectResponse($ex, $done_uri);View on GitHub (pinned to 5720a38cfe)
Solutions
- Exclude the source PHID from any list you feed to the dialog: array_diff($phids, array($src_phid)).
- If you hit it in the UI, just remove the object from the selection - the dialog shows which PHID offended in the message.
- For scripts, filter self-references before building the request.
- No configuration exists to allow self-relationships; model true self-loops differently (e.g. a separate linked-object field).
Example fix
// before $add_phids = array_diff($phids, $initial_phids); // after: also drop self-references $add_phids = array_diff($phids, $initial_phids, array($src_phid));
Defensive patterns
Strategy: validation
Validate before calling
$add_phids = array_diff($phids, $initial_phids, array($src_phid));
Type guard
function hasNoSelfReference($src_phid, array $add_phids) { return !in_array($src_phid, $add_phids, true); } Try / catch
try {
$this->applyRelationshipChanges($object, $add, $rem);
} catch (Exception $ex) {
return $this->newUnrelatableObjectResponse($ex, $done_uri);
} Prevention
- Filter the current object's PHID out of any generated list before POST
- Typeahead config for relationship dialogs should exclude the source object
- When computing dependency graphs in scripts, skip edges where src === dst
When it happens
Trigger: POSTing the object's own PHID in the add list - e.g. adding a task to its own subscribers, setting a task as blocking itself ('Maniphest Task: T123'), or dragging the same object into its relationship tokenizer via paste (paste the current object's URI, which the tokenizer resolves to its PHID).
Common situations: Users pasting the object URL into the dialog's typeahead out of curiosity; scripts that compute related-object sets with an off-by-one including the root; merging tasks where source and destination coincide.
Related errors
- You can not create a relationship (of type "%s") to object "
- Too many relationships (%s, of type "%s").
- Service "%s" is unrecognized, restricted, or you do not have
- When creating a new Almanac interface via the Conduit API, y
- Device "%s" is unrecognized, restricted, or you do not have
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/bba9b0a17d9b41f6.
Report an issue: GitHub.