OrchardCMS/OrchardCore · error · InvalidOperationException
Missing table alias for path
Error message
Missing table alias for path {alias.alias}. What it means
PredicateQuery.GetColumnName resolves an alias path to its physical column: after finding the alias it must look up the corresponding table alias in _tableAliases. When the alias record exists but its 'alias' key is absent from _tableAliases — the table join was never registered for that predicate path — the method throws InvalidOperationException so the query does not generate SQL against a missing table.
Solutions
- Register the table alias (via SetTableAlias/join logic) for the path before evaluating predicates.
- Fix the alias path in the query so it matches a registered alias+table pair.
- Recreate/refresh the index profile so alias and table registrations agree.
Example fix
// before
predicateQuery.SetAlias("SomePath", "SomeIndex"); // alias added, but table alias never set
// after
predicateQuery.SetTableAlias("SomeIndex", "SomeTable"); // register the table join too
predicateQuery.SetAlias("SomePath", "SomeIndex"); Defensive patterns
Strategy: validation
Validate before calling
// before resolving columns, ensure every alias path has a table alias
foreach (var (path, alias) in aliases)
if (!predicateQuery.HasTableAlias(alias.alias)) throw new InvalidOperationException($"Path '{path}' has no registered table alias '{alias.alias}'."); Try / catch
try { var column = predicateQuery.GetColumnName(aliasPath); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Missing table alias")) { _logger.LogError(ex, "Unjoined table for predicate path {Path}", aliasPath); throw; } Prevention
- Always call SetTableAlias for an index before adding predicates on it.
- Centralize alias registration so joins and aliases are added together.
- Validate saved queries against current index profiles after schema changes.
When it happens
Trigger: Building a predicate/where clause for a path whose alias was added to _aliases but whose table alias was never registered (e.g. a filter path referencing an index/table that was not joined, or aliases registered out of order when composing the query).
Common situations: Custom GraphQL/Queries predicate referencing a field whose index table is not part of the query; typo in alias path so it resolves to a different alias; index profile changed after the query was saved.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- An ambiguous index has been found.
- The terms lookup query is not supported
- Invalid terms query
- Missing value in wildcard query
- Invalid wildcard query
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/13efe60c0b09ff2d.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Predicates/PredicateQuery.cs:137
}
return EnsureQuotes(tableAlias, alias.alias);
}
return EnsureQuotes(alias.alias);
}
var index = IndexOfUnquoted(propertyPath, '.');
// if empty prefix, use default (empty alias)
var aliasPath = index == -1 ? string.Empty : propertyPath[..index];
// get the actual index from the alias
if (_aliases.TryGetValue(aliasPath, out alias))
{
if (!_tableAliases.TryGetValue(alias.alias, out var tableAlias))
{
throw new InvalidOperationException($"Missing table alias for path {alias.alias}.");
}
// get the index property provider fore the alias
var propertyProvider = _propertyProviders.FirstOrDefault(x => x.IndexName.Equals(alias.alias, StringComparison.OrdinalIgnoreCase));
if (propertyProvider != null)
{
if (propertyProvider.TryGetValue(propertyPath[(index + 1)..], out var columnName))
{
// Switch the given alias in the path with the mapped alias.
// aliasPart.alias -> AliasPartIndex.Alias
return EnsureQuotes(tableAlias, columnName);
}
}
else
{
// no property provider exists; hope sql is case-insensitive (will break postgres; property providers must be supplied for postgres)
// Switch the given alias in the path with the mapped alias.View on GitHub (pinned to 4306c0717f)