iOfficeAI/OfficeCLI · error · CliException

invalid_selector

invalid_selector

Error message

Wildcard sheet scope ('*/row[...]') is not supported — omit the sheet prefix entirely; an unscoped row[...] searches every sheet.

What it means

Thrown by QueryRowsByColumnPredicate when the row[...] selector is scoped with a literal '*' sheet (e.g. '*/row[Salary>5]'). Wildcard sheet scope is not a feature; the unscoped form row[...] already searches every sheet, so the '*' would otherwise be read as a literal sheet named '*' and produce a baffling 'no table on sheet' error.

Source

Thrown at src/officecli/Handlers/Excel/ExcelHandler.Query.RowWhere.cs:70

        var m = Regex.Match(key, @"^col(?:umn)?\.(.+)$", RegexOptions.IgnoreCase);
        return m.Success ? m.Groups[1].Value : key;
    }


    // Match table data rows whose cells satisfy every column predicate. Auto-
    // binds to the single ListObject that owns all referenced columns; throws on
    // no-match or cross-table ambiguity rather than silently picking one.
    private List<DocumentNode> QueryRowsByColumnPredicate(string? sheetFilter, AttributeFilter.FilterExpr expr)
    {
        // Distinct leaf predicates drive column resolution and probe building; the
        // expression tree (which may be `or` / parens, e.g. row[金额>5 or 金额<1])
        // drives the actual row match via MatchesExpr.
        var colConds = AttributeFilter.LeafConditions(expr).ToList();
        // `*/row[...]` reads as a literal sheet named "*" and would report the
        // baffling "no table on sheet '*'". Wildcard sheet scope is not a
        // thing — the UNSCOPED form already searches every sheet.
        if (sheetFilter == "*")
            throw new Core.CliException(
                "Wildcard sheet scope ('*/row[...]') is not supported — omit the sheet prefix entirely; " +
                "an unscoped row[...] searches every sheet.")
            { Code = "invalid_selector", Suggestion = "row[...] (no sheet prefix) searches all sheets" };
        // A table that owns every referenced column. ListObjects are
        // authoritative (column names are stored metadata); detected tables are
        // a header-sniff heuristic (stable=false), so they are only consulted
        // when no ListObject matches — a real table never loses to a guess.
        var listObjCands = new List<(string sheetName, WorksheetPart part, string label, string source,
            int dataR1, int dataR2, Dictionary<string, int> colAbsIndex)>();
        var detectedCands = new List<(string sheetName, WorksheetPart part, string label, string source,
            int dataR1, int dataR2, Dictionary<string, int> colAbsIndex)>();
        // Every table in scope with its header names — used only to build a
        // helpful "no such column" error (list all when few, suggest similar
        // when many). Collected regardless of whether a table resolves the
        // predicate, so a typo'd column still surfaces the real names.
        var scopeTables = new List<(string label, List<string> cols)>();

        foreach (var (sheetName, worksheetPart) in GetWorksheets())

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Omit the sheet prefix entirely: use 'row[Amount>100]' so the query searches every sheet.
  2. To restrict to one sheet, use its explicit name: '/SheetName/row[Amount>100]'.

Example fix

// before
/Sheet1/*/row[Amount>100]
*/row[Status='open']

// after
row[Amount>100]            // searches every sheet
/Sheet1/row[Status='open'] // restricted to one sheet
Defensive patterns

Strategy: validation

Validate before calling

if (sheetFilter == "*")
    throw new ArgumentException("Wildcard sheet scope is unsupported; use row[...] without a sheet prefix.");

Prevention

When it happens

Trigger: Issuing a selector like '/*/row[Amount>100]' or passing sheetFilter="*" to the underlying query API.

Common situations: An LLM or user trained on glob/SQL wildcards assuming '*' means 'all sheets'; transposing the CSS/XPath wildcard habit onto the path grammar.

Related errors


AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13). Data as JSON: /api/errors/b8cd3532d5de7f4e. Report an issue: GitHub.