phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\UnknownRelationType
Unknown relation type
Error message
Unknown relation type
What it means
Thrown in ModelsManager::getRelationRecords when the relation's type matches none of the known cases (HAS_MANY_THROUGH, HAS_ONE_THROUGH, and implicitly the simple types) — a sentinel 'unreachable in practice' guard indicating a corrupted/unknown relation type value on the Relation object.
Solutions
- Ensure relations are created only through the manager's addBelongsTo/addHasOne/addHasMany/addHasOneThrough/addHasManyToMany helpers
- Do not mutate a Relation's type after creation; rebuild the relation instead
- If a custom Relation subclass is used, return one of the documented Relation type constants
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Manager.zep:1499 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/8c41cf727f31b947.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Manager.zep:1499
let records = this->getReusableRecords(referencedModel, uniqueKey);
if typeof records == "array" || typeof records == "object" {
return records;
}
}
switch relation->getType() {
case Relation::HAS_MANY_THROUGH:
let records = query->execute();
break;
case Relation::HAS_ONE_THROUGH:
let records = query->setUniqueRow(true)->execute();
break;
default:
throw new UnknownRelationType();
}
if reusable {
this->setReusableRecords(referencedModel, uniqueKey, records);
}
return records;
}
let conditions = [];
/**
* Appends conditions created from the fields defined in the relation
*/
let fields = relation->getFields();
/**
* Compound relationView on GitHub (pinned to b7419de9cd)