Skip to content

Allow group names in abstract-group label search boxes - #7173

Open
roed-math wants to merge 4 commits into
LMFDB:mainfrom
roed-math:ai/t36-group-name-search
Open

Allow group names in abstract-group label search boxes#7173
roed-math wants to merge 4 commits into
LMFDB:mainfrom
roed-math:ai/t36-group-name-search

Conversation

@roed-math

Copy link
Copy Markdown
Contributor

Closes #6397.

Search boxes in the abstract groups section that take group labels (center, commutator, central quotient, abelianization, automorphism group, outer automorphism group, Frattini subgroup; subgroup/ambient/quotient in the subgroup search; group/image in the complex character search) now also accept group names, e.g. C6, S4, D8, Q8, C2^3, C2xC4, SL(2,7), GL(2,3), 8T3, and light TeX variants like C_2^3 or C_2\times C_4.

Names are resolved to labels by a new name_to_label helper that reuses the jump box's resolution paths (stored names, cyclic products via primary invariants, special family names, transitive labels), so a name works in a search box iff it works in the jump box.

Comma-separated lists may mix labels, names, and (where previously allowed) orders. Only top-level commas split the list, so a family name whose parameters contain a comma stays in one piece, and unbalanced delimiters or empty entries give the section's search-input error. A + inside a name such as SO+(4,2) is preserved, while a leading unary + on an order or label is still accepted. Unknown or ambiguous names produce a search-input error naming the offending entry.

Adds tests pairing each name search with the existing sibling label test so the two stay in sync.

Composes with the multi-label Find box work in #7170: that change is an additive block at the top of group_jump, placed before name resolution.


Ported from roed-math#39, where the full write-up and comment history live.

🤖 Generated with Claude Code

roed314 and others added 3 commits July 19, 2026 13:44
Group-label search boxes in the abstract groups section (center,
commutator, central quotient, abelianization, aut/outer group, Frattini;
subgroup/ambient/quotient; character group/image) now accept group names
such as C6, S4, D8, Q8, C2^3, C2xC4, SL(2,7), GL(2,3), 8T3 and TeX-ish
variants, resolved to labels by a new name_to_label helper reusing the
jump-box resolution paths (stored names, cyclic products, special family
names, transitive labels).  Unknown or ambiguous names give a search
input error naming the offending entry.

Verified with sage -python parser-level checks (name queries identical
to label queries) and flask test client via pytest (new tests
test_search_by_name, test_search_by_name_subgroups,
test_search_by_bad_name plus sibling label tests: 14 passed); pyflakes
clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both parsers added by the previous commit tokenized their input with
inp.split(","), so a family name whose parameters contain a comma, such
as SL(2,7) or GL(2,3), was chopped into SL(2 and 7) and never reached
name_to_label -- exactly the names the search boxes advertise.

split_group_search_terms now splits only at commas outside (), [] and {},
and raises SearchParsingError for unbalanced delimiters or empty entries
so that they give the section's normal search input error rather than a
complaint about a truncated name.  Both parse_group_label_or_order_or_name
and parse_group_label_or_name use it.  (split_top_level_commas in
search_wrapper.py is deliberately lenient for jump boxes, so it is not
reused here.)

parse_group_label_or_order_or_name also dropped prep_plus=True, which
deletes every + in the input; that was harmless for labels and orders,
but it mangles the stored name SO+(4,2) (= 72.40) now that names are
accepted.  A leading unary + is instead stripped from each entry, so +8
and +8.3 keep working while an internal + is preserved.

Tested with sage -python -m pytest lmfdb/groups/: the three affected
tests (test_search_by_name_with_commas, test_search_by_name_with_plus,
test_search_by_bad_name) fail on 6bcfa82 and pass here; pyflakes clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jenpaulhus

Copy link
Copy Markdown
Contributor

It looks like this currently errors if you put "bird" as a group name in any of the search boxes. It does say

psycodict.utils.SearchParsingError: bird is not a valid group label or name

But it throws an error on the page instead of showing the search page again with the error message at the top.

Reported on LMFDB#7173: entering an unrecognized group name such as "bird"
in one of the group label search boxes gave a traceback page rather than the
search page with the error message at the top.

Wrapper.make_query re-raised every parsing error when app.debug is set, so
this happened for any invalid search input in any section (e.g. order=bird
on main does the same); the new name errors just made it visible.  A
SearchParsingError describes a problem with the user's input rather than a
bug, so redisplay the search page for it in debug mode too.  Other
exceptions raised while parsing are still re-raised, so developers keep
getting a traceback for actual bugs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@roed-math

Copy link
Copy Markdown
Contributor Author

Thanks, good catch. The message was right but the presentation was wrong, and the cause turned out to be more general than this PR.

Wrapper.make_query in lmfdb/utils/search_wrapper.py re-raised every exception from parsing whenever app.debug is set:

except Exception as err:
    # Errors raised in parsing; these should mostly be SearchParsingErrors
    if is_debug_mode():
        raise

So if the site is started with -d (or has debug = True sitting in config.ini, which start-lmfdb.py writes out after you use -d once), any invalid search input in any section gives a traceback page instead of the search page. On current main, /Groups/Abstract/?order=bird and /EllipticCurve/Q/?conductor=bird behave exactly the same way. With debug off, the group name boxes on this branch already redisplayed the search page with the error at the top, which is what lmfdb.org does.

Since a SearchParsingError reports a problem with the user's input rather than a bug, 61a67c5 makes make_query redisplay the search page for it in debug mode too. Anything else raised while parsing is still re-raised, so a real bug still gets you a traceback.

bird now gives the search page with

Error: bird is not a valid input for Aut group. bird is not a valid group label or name

at the top in both modes. The commit adds test_search_by_bad_name_in_debug_mode, which runs the group, subgroup and complex character searches with app.debug set; it fails with the exact SearchParsingError traceback you saw without the one line fix. All 84 tests in lmfdb/groups/abstract/ pass.

One thing worth flagging: that commit touches shared code and so changes debug-mode behavior for every section, not just groups. I think it is the right call, since bad input is not a bug and should not look like one, but I am happy to pull it out into its own PR if you would rather keep this one confined to the group name search.

@jenpaulhus

Copy link
Copy Markdown
Contributor

LGTM now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow entering group names into search boxes

3 participants