Repository navigation
Reject "|" in topic short names (#1488) - #1506
Conversation
A ProjectUmbrella short_name containing the Projects-page topic delimiter splits into bogus topics in the card's data-project-keywords. These tests expect full_clean() and the admin add view to reject it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Projects page joins each card's topic short names with "|" and the filter JS splits on it, so a short name containing "|" silently broke filtering for that topic. ProjectUmbrella.clean() now rejects it with an error on the field. A model clean() rather than a field validator keeps the field's deconstruction unchanged, so no migration is generated. The model now owns the delimiter as SHORT_NAME_DELIMITER; the listing filter tests take it from there, so the template, JS and model are pinned to one value. Comments at the JS constant and the card template point at the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonfroehlich
left a comment
There was a problem hiding this comment.
Review 1 (Fable 5.2) of head 169be16
Verdict: no blocking and no should-fix findings. Every claim in the PR body that I could re-derive holds. Four nits below, none of which needs to hold the merge.
Local runs used Python 3.13 in the makeabilitylabwebsite-website image (stale, built 2026-12-01) with --settings=makeabilitylab.settings_test and a throwaway Postgres.
Claims re-derived
| Claim | Result |
|---|---|
| Failing first | Confirmed. At 5b9dcc9 (tests only) the two modules run 13 tests with 2 failures: 302 != 200 in the admin test and ValidationError not raised in the unit test. At head: 13 tests, OK. |
| Full-suite counts | Confirmed. Head: 1220 tests, 34 skipped, 2 failures. Base a643f99: 1217 tests, 34 skipped, the same 2 failures (test_cleaner_kwargs_match_snapshot, test_hide_elements_includes_installed_toolbar_host). Both come from the stale local image and are not findings. |
| CI | test, e2e and a11y pass on this head. |
| No migration | Confirmed. I generated a migration history from base's models, copied it under head, and ran makemigrations website --check --dry-run with the plain settings: "No changes detected in app 'website'", exit 0. The check is sensitive: changing max_length on the field makes it exit 1 with an AlterField. |
| "+" popup path | Confirmed by probe. A POST to the add view with _popup=1 and `AR |
| Editors are covered | Confirmed. A user in the Editors group posting `AR |
| The issue's delimiter-agreement point was already stale | Confirmed. KeywordDelimiterAgreementTests landed in 8de15f5 (2026-12-01), an ancestor of base; the issue was filed 2026-12-04. |
| Existing data | Confirmed today: production shows 14 topic buttons and the test server 9, none containing ` |
| The admin is the only write path | Confirmed by grep: no management command, fixture, API write or list_editable touches ProjectUmbrella. |
| Template comment stays single-line | Confirmed. |
Other probes that passed:
- A stored name containing
|blocks any edit until it is renamed; renaming it saves, and deleting it still works. " A|B "is rejected.short_name=Noneand""give the ordinary field errors.- The rendered error is HTML-escaped and attached to the field.
Mutations (against the two test modules)
| Mutation | Caught? |
|---|---|
Drop clean() |
Yes |
Model constant to , |
Yes |
JS constant to , |
Yes |
Template delimiter to , |
Yes |
Model and JS to ,, template left at | |
Yes |
Non-field error instead of a short_name error |
Yes |
Also reject / |
Yes |
== instead of in |
Yes |
Drop the or "" guard |
No (nit 2) |
| Change the message text | No (nit 2) |
Findings (all nits)
- The "+" popup path is relied on but not pinned.
- The only admin test posts to the plain add view.
- It works today (probe above). One extra POST with
_popup=1would pin it. Low value, since it is the sameModelAdmin.
- Two untested lines in
clean().- Removing
or ""leaves every test green, yetProjectUmbrella(name="n", short_name=None).full_clean()would then raiseTypeErrorinstead ofValidationError. - The message wording is also unpinned.
- Fix: add
Noneto the unit test, and optionally assert that|appears in the message.
- Removing
clean()reads the stored value, not the submitted one, when the field fails its own validation.- Reproduction: create a row with
short_name="A|B"viaobjects.create(), then POST a blank or 300-charactershort_nameto its change view. The form shows the|error beside the real field error, although the submitted value has no|. - Related latent case: a
ModelFormthat leavesshort_nameout would raiseValueError: ... has no field named 'short_name'on such a row. No form in the repo excludes that field, so nothing reaches this today. - Both need a pre-existing row with
|, and none is visible on either site. - Optional fix: do the check in
clean_fields(self, exclude=None)and skip it whenshort_nameis excluded. That also adds no migration.
- Reproduction: create a row with
- The PR body undercounts the popup hosts. The Grant add form also renders the
project_umbrellas"+" link (Video does not). SameModelAdmin, so behaviour is unaffected; a wording correction only.
Not verified
- Topics attached to no visible project on either server (needs database access; the PR says the same).
- The Playwright and Pa11y suites locally. I relied on the green CI jobs; the only browser-loaded change is a JS comment.
Second review: Gemini 4 Neon (xhigh) (gemini-4-neon-xhigh)
Gemini reviewed the same diff (base a643f99, 5 files, 166 lines; no files excluded) and reported 2 findings. I triaged each by reproducing it.
| # | Where | Gemini's finding | Severity if true | Verdict |
|---|---|---|---|---|
| 1 | website/models/project_umbrella.py, def clean(self): |
clean() ignores Django's exclude list and validates a stale stored value; suggests clean_fields(exclude=None) |
nit | Partly valid |
| 2 | website/tests/test_project_umbrella.py, def setUp(self): |
setUp() omits super().setUp(), so base-class initialization is skipped |
should-fix | Rejected; withdrawn by Gemini |
Finding 1, partly valid.
- The stale-value half is confirmed and is my nit 3 above.
- The excluded-form half is mis-described: the result is a
ValueError, not a non-field error. It is also unreachable today, because no form excludesshort_name. - The suggested
clean_fieldsfix is sound and optional.
Finding 2, rejected.
DatabaseTestCasedefines nosetUp; it only provides themake_*helpers.- Django's
TestCasedoes its per-test work in_pre_setup(), beforesetUp(). - The two
DatabaseTestCasesubclasses already intest_project_listing_filter.pyoverridesetUpthe same way. - The new module passes alone and inside the full suite.
Follow-up. I sent Gemini one rebuttal, on finding 2. It replied "I withdraw the finding", agreeing that nothing is skipped and that a super().setUp() call would only be defensive future-proofing. Nothing is left in dispute.
🤖 Generated with Claude Code — review, triage and verdicts by Fable 5.2, claude-fable-5-2; second-review findings by gemini-4-neon-xhigh via Google Antigravity CLI
Pins the "+" popup add view, None/"" short names, and the error message. Two new tests fail on the current clean(): it reports a stored "|" when the submitted short name is itself invalid, and a ModelForm without short_name raises ValueError on a row that already holds "|". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eview) clean() ran even when short_name was excluded from model validation, so it reported a row's stored "|" when the submitted short name had failed its own validation, and raised ValueError in a ModelForm that leaves short_name out. clean_fields() skips an excluded or already-invalid short_name, which also makes the None guard unnecessary. Still no migration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix round 1: replies to review 1I reproduced each finding before changing anything. The new tests were committed first (eda04de) and run against the previous head's model: The popup,
Local verification: 🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5 |
jonfroehlich
left a comment
There was a problem hiding this comment.
Review 2 (Fable 5.2) of head a0c5ffa
Covers the fix range 169be16..a0c5ffa (2 commits, 5 files) and the fix-round replies to review 1.
Verdict: no blocking and no should-fix findings. Every review 1 finding is closed and the fixes broke nothing. Three nits below, all optional.
Local runs used Python 3.13.1 and Django 5.2.19 in the makeabilitylabwebsite-website image (stale) with --settings=makeabilitylab.settings_test and a throwaway Postgres 16. CI on this head: test, e2e and a11y pass.
Review 1 findings
| Finding | Closed? | How I checked |
|---|---|---|
| Fable 1: the "+" popup path was not pinned | Yes | test_admin_popup_add_with_pipe_shows_field_error_and_creates_nothing fails when the delimiter check is removed. |
Fable 2: or "" and the message were untested |
Yes | or "" is gone; None and "" each give exactly one ordinary field error. Removing "|" or the AR/VR hint from the message each fails the unit test. |
Fable 3 / Gemini 1: a stored | was reported against a different submitted value; a form excluding short_name raised ValueError |
Yes | Putting the 169be16 clean() back reproduces the reply's failing-first claim exactly: ValueError in the excluded-form test and 2 != 1 in the stored-pipe test. Both pass at head. |
| Fable 4: the PR body omitted Grant | Yes | The body now reads "Project/Publication/Talk/Poster/Grant". |
Gemini 2: super().setUp() |
No change, correctly | Gemini withdrew it in review 1. |
Nothing broke
- Full suite at head: 1224 tests, 34 skipped, 2 failures (
test_cleaner_kwargs_match_snapshot,test_hide_elements_includes_installed_toolbar_host). - The same two on base a643f99: I re-ran those two modules there and both fail identically. They come from the stale local image and are not findings.
- No migration: I generated a migration history from base a643f99's models, copied it under head, and ran
makemigrations website --check --dry-runwith the plain settings: "No changes detected in app 'website'", exit 0. The check is sensitive: changing the field'smax_lengthgives anAlterFieldand exit 1.
Mutations (against test_project_umbrella and test_project_listing_filter, 17 tests)
| Mutation | Caught? |
|---|---|
Drop the exclude check |
Yes |
| Drop the already-failed check | Yes |
Revert to clean() |
Yes |
Message without "|" |
Yes |
Message without the AR/VR hint |
Yes |
| Remove the delimiter check | Yes |
== instead of in |
Yes |
Non-field error instead of a short_name error |
Yes |
Don't call super().clean_fields() |
Yes |
Discard the errors super() raised |
Yes |
| The delimiter error replaces the other fields' errors | No (nit 1) |
exclude instead of (exclude or ()) |
No (nit 2) |
super().clean_fields() without passing exclude |
No (nit 2) |
Probes of the clean_fields() override (all passed)
- Admin add view.
AR/VRsaves;X|Yreturns 200 with no row. The same holds for a user in theEditorsgroup. - Admin change view, on a row stored as
A|B:- re-posting
A|B, or postingC|D, is refused; - a 300-character value shows only the max-length error;
- a blank name with a blank short name shows one "required" error on each;
A|Bwith a blank name shows the name error and the delimiter error;- renaming to
A/Bsaves, and delete and the changelist still work.
- re-posting
- "+" popup. A valid add returns the popup response. An invalid add re-renders as a popup with the error on the field. A rename through the popup change view saves.
- Error key and placement. The key is
short_name, there are no non-field errors, and the message renders HTML-escaped inul.errorlist#id_short_name_errorinside the field's own form row. full_clean(exclude=...). A list, set or tuple namingshort_nameskips the check.None, an empty list or set, and excludes naming other fields still reject. A directclean_fields()call works with and withoutexclude.- Other call paths. Nothing in the repo calls
full_clean()orclean_fields()onProjectUmbrellaoutside the tests, and the API only reads umbrella names. An all-fieldsModelForm, ashort_name-only form and a model formset each put the error onshort_name. - Edge values.
" A|B "is rejected. 300 pipes give only the max-length error. An integer is coerced to a string by the field before theintest, so there is noTypeError.
Findings (all nits)
- Merging with other fields' errors is not pinned.
- Defect: if
clean_fields()replaced the error dict fromsuper()with only its own error, no test would notice. - Reproduction: insert
errors = {}beforeerrors["short_name"] = [...]. The 17 tests stay green, yetProjectUmbrella(name="x" * 300, short_name="A|B").full_clean()then loses thenameerror. - Reach is low: in the admin the form reports
nameerrors itself, so only directfull_clean()callers are affected. - Fix: one assertion that both
nameandshort_nameare inmessage_dictfor that instance.
- Defect: if
- Two argument-handling details are unpinned.
(exclude or ())→excludesurvives, becausefull_clean()always passes a set. Only a directclean_fields()call would then raiseTypeError.super().clean_fields()withoutexcludealso survives; catching it needs an excluded field that holds an invalid stored value.- Fix, if wanted: one direct
clean_fields()call in the unit test. Low value.
- The PR body's full-suite count is stale. It still says "this branch: 1220 tests"; this head runs 1224, with the same 34 skipped and the same 2 failures. Wording only.
Not verified
- The Playwright and Pa11y suites locally. I relied on the green
e2eanda11yjobs; the range changes only comments in the JS and the template. - That the Grant add form renders the "+" link. I took that from review 1.
Second review: Gemini 4 Neon (xhigh) (gemini-4-neon-xhigh)
Gemini reviewed the same range (base 169be16, 5 files, 185 diff lines; no files excluded) and reported 0 findings. There was nothing to triage or rebut.
Its reasoning trace reached me truncated: I could read the opening and the closing part, not the middle. In what I could read, it raised these concerns and dropped each one itself:
| Concern Gemini considered | Its conclusion | My check |
|---|---|---|
A deferred short_name might be mishandled by clean_fields() |
Dropped as speculation; it also asserted that full_clean() excludes deferred fields automatically |
Not a defect, but that assertion is wrong on Django 5.2.19. I loaded a stored `A |
None or "" might reach the delimiter check |
Dropped: the field's own validation fails first | Agrees with the already-failed mutation above. |
exclude passed as a one-shot iterator |
Dropped: the framework converts it | full_clean() passes a set; lists, sets and tuples all behave (probe above). |
Mutating e.error_dict and re-raising might alias or lose error codes |
Dropped: the dict is rebuilt intact | Agrees with the mixed-errors probes above. |
| The popup test and the formset prefix in the test helper | Sound; a helper's name called "stylistic" | Agreed. |
🤖 Generated with Claude Code — review, triage and verdicts by Fable 5.2, claude-fable-5-2; second-review findings by gemini-4-neon-xhigh via Google Antigravity CLI
The delimiter error must join the stock field errors rather than replace them, and a direct clean_fields() call must accept exclude=None or a list and pass it on to the stock validation. Each test fails under the matching mutation of clean_fields(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix round 2: replies to review 2I reproduced all three nits first. Each of the review's three surviving mutations, applied to
Verification: locally, 🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5 |
Closing check: nothing foundRead at head 0024821: the whole PR diff against base a643f99 (5 files), plus both reviews and both fix-round replies, treated as claims to check. Review findings. Neither review, including the two Gemini passes, raised a blocking or should-fix finding. Their nits are all closed at this head:
Commits after review 2 (a0c5ffa..0024821). One commit, 18 added lines in
Consistency across files. The PR body, the model docstrings, the JS comment, the template comment (still one line) and the test-module comments all name Not verified. The Playwright and Pa11y suites locally (I relied on the green CI jobs), and topics that are not shown on 🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2 |
Closes #1488
Summary
A topic (
ProjectUmbrella) short name containing|silently broke the Projects-page filter: each card lists its topics' short names joined by|, andproject-listing-filter.jssplits on it, soAR|VRbecame two bogus topics that never match their own button. The admin accepted such a name without complaint.ProjectUmbrella.clean_fields()now rejects it, with the error shown on theshort_namefield:website/models/project_umbrella.py: class constantSHORT_NAME_DELIMITER = "|", aclean_fields()override (runs the field validation first, then the delimiter check, skipped whenshort_nameis excluded or already invalid), docstrings. (Moved fromclean()in review round 1, so a stored "|" is never reported against a different submitted value.)website/tests/test_project_listing_filter.py: the module's ownKEYWORD_DELIMITER = "|"now comes fromProjectUmbrella.SHORT_NAME_DELIMITER, so the existing tests pin the template, the JS and the model to one value.website/tests/test_project_umbrella.py(new):full_clean()rejectsAR|VRon the field;Maker/Design Tools,Augmented Reality,E-Textiles,AR/VRstill pass (pin against over-rejecting); the admin add view returns 200 with ashort_nameerror and creates no row. Added in review round 1: the same through the "+" popup (_popup=1);None/""give only the ordinary field error; the message names"|"and suggestsAR/VR; a storedA|Brow edited with a blank short name shows only the blank-field error; and a ModelForm withoutshort_namecan still edit such a row.KEYWORD_DELIMITERin the JS and in the (still single-line){# #}indisplay_project_snippet.html.No change to the view, CSS, JS logic, e2e tests or anything a browser loads, so there is no cached-script risk.
Decisions (PROVISIONAL, pending Jon)
clean_fields()), not a field validator, so no migration.help_textleft alone (changing it would auto-generate anAlterField).short_namecollapse into one filter button with a wrong count (the view's dict is keyed on the non-uniqueshort_name; filtering itself still works). Labels would beBug,Projects,Project Gallery Page.Notes
KeywordDelimiterAgreementTests(8de15f5) pins the JS constant, andtest_card_lists_each_topic_wholesplits the rendered attribute on the same constant. Re-pointing that constant at the model is therefore a pin, not a regression test./projects/contains|. Topics attached to no visible project can't be checked without DB access; if one does contain|, the admin will refuse to save any edit to it until it is renamed. That is the intended surfacing.objects.create(), shell andloaddatabypass it). Acceptable, since the admin, including the "+" popup on Project/Publication/Talk/Poster/Grant, is the only write path.Tests, failing first
New tests committed alone (5b9dcc9) and run against the unchanged model:
(302 = the add view saved the row.)
Full suite, Python 3.13.1 in the local
makeabilitylabwebsite-websiteimage,--settings=makeabilitylab.settings_test:The two failures (
test_news_prose_editor ... test_cleaner_kwargs_match_snapshot,test_pa11y_ci_config ... test_hide_elements_includes_installed_toolbar_host) come from the stale local image (django-prose-editor and django-debug-toolbar older than the pins) and fail identically on base. CI builds from the pins.No migration: I exported the base tree, ran
makemigrations websitethere to produce a migration history from master's models, copied that history into an export of this branch, and ranmakemigrations website --check --dry-run: "No changes detected in app 'website'", exit 0.No screenshots: the only UI change is an admin field error message.
🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5