Skip to content

Hide private projects from auto-generated member bios - #1469

Open
jonfroehlich wants to merge 2 commits into
masterfrom
bio-hides-private-projects
Open

jonfroehlich wants to merge 2 commits into
masterfrom
bio-hides-private-projects

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

Problem

Auto-generated bios on public member pages (website/utils/bio_utils.py, _contributions_sentence) named every project a person had a role on, including hidden projects (is_visible False/None). So the names of hidden projects showed up on public member pages even though the project pages themselves 404.

Fix

Filter person.get_projects to visible projects before building the sentence, using the same truthy check as views.member.get_member_projects (None counts as hidden). A person whose only projects are hidden gets no project clause.

Tests

  • test_hidden_projects_are_not_named: mixed visible / False / None projects; only the visible one is named.
  • test_only_hidden_projects_and_no_pubs_has_no_contributions: no "contributed to" sentence.
  • Both failed before the fix. Full suite (--settings=makeabilitylab.settings_test) passes locally.

No UI change beyond bio text, so no screenshots.

🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5

The auto-generated bio on public member pages listed every project a
person has a role on, including hidden (is_visible=False/None) ones.
Filter to visible projects, matching the truthy check used by
views.member.get_member_projects.

Adds regression tests for a mix of visible/hidden projects and for a
person whose only projects are hidden.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68

@jonfroehlich jonfroehlich left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 2bcffdcc327e899bb2c9dcf46df414ffc6746143 against origin/master (6688489). Review round 1, comment only.

No blocking findings. The fix does what the description says. One should-fix (test coverage) and two nits below.

What I checked

Each claim in the description, in a clean Postgres 16 and the project image (Python 3.13.1):

Claim Result
Bios named hidden projects before the fix Reproduced. With bio_utils.py from origin/master, a DB-backed probe (real Person, Position and ProjectRole rows; one visible project, one is_visible=False, one is_visible=None) shows both hidden names in the rendered member page.
Fixed at this head Yes. Same probe: neither hidden name appears anywhere in the member page response (bio, meta description, projects grid), anonymous or logged in as staff. The visible project is still named, as "a project called ...".
Same truthy check as get_member_projects Yes, if proj.is_visible in both; None is hidden.
Only hidden projects gives no project clause Yes. No "contributed to" sentence with no publications; with one publication the sentence is "They contributed to 1 publication."
Both new tests failed before the fix Yes, both fail with the base bio_utils.py.
Full suite passes Yes: 831 tests, OK, 8 skipped.

auto_generate_bio has one caller (views.member.member), and its result feeds both the bio block and the meta description, so the one filter covers both. The bio is not stored or serialized anywhere else.

Scope of this review: the member page only.

Mutation results

Each mutant replaced website/utils/bio_utils.py; the tests were the PR's test_bio_utils.py.

Mutant PR tests
Filter removed (base file) killed (both new tests)
is_visible is not False (None counts as visible) killed
is_visible is not None (False counts as visible) killed
Filter inverted (not p.is_visible) killed
Names filtered, count taken from the unfiltered list killed
Filter applied only when no project is visible killed
is_visible is True survives; equivalent for a nullable boolean, not a gap
Count filtered, names taken from the unfiltered sorted list survives (nit 2)

Findings

1. should-fix: no DB-backed regression test for the leak. The two new tests use MagicMock people and projects, so nothing exercises the real Person.get_projects or the member view. With the filter removed, the DB-backed suites that render member and project pages (test_member_artifacts, test_views, test_page_metadata, test_view_smoke, test_project_visibility, test_project_page; 85 tests) all still pass; I ran that. The only guard is the mocked pair. CLAUDE.md asks for a regression test "in the matching style" when a bug is reachable through a real view, and this one is. A test along these lines passes at this head and fails on base (verified):

class MemberBioVisibilityTests(DatabaseTestCase):
    def test_member_page_does_not_name_hidden_projects(self):
        person = self.make_person(first_name="Probe", last_name="Person")
        Position.objects.create(person=person, start_date=date(2020, 1, 1),
                                title=Title.PHD_STUDENT)
        shown = self.make_project(name="Zq Shown", is_visible=True)
        hidden = self.make_project(name="Zq Hidden", is_visible=False)
        unset = self.make_project(name="Zq Unset", is_visible=True)
        Project.objects.filter(pk=unset.pk).update(is_visible=None)  # legacy NULL row
        for proj in (shown, hidden, unset):
            ProjectRole.objects.create(person=person, project=proj,
                                       start_date=date(2021, 1, 1))
        person.refresh_from_db()
        html = self.client.get(reverse(
            "website:member_by_name",
            kwargs={"member_name": person.url_name})).content.decode()
        self.assertIn("a project called", html)
        self.assertIn("Zq Shown", html)
        self.assertNotIn("Zq Hidden", html)
        self.assertNotIn("Zq Unset", html)

2. nit: the fixture's name order lets a mutant through. In test_hidden_projects_are_not_named the visible project ("Public One") sorts before both hidden ones ("Secret", "Unset"). A version that counts only visible projects but takes the displayed names from the unfiltered sorted list still passes, because projects[0] happens to be the visible one. Reproduced: that mutant passes all of test_bio_utils.py. Renaming so a hidden project sorts first (for example "Alpha Hidden") kills it. A second case with two visible projects plus a hidden one, asserting "2 projects:", would also pin the count on the multi-project path.

3. nit: third copy of the visibility rule for a person's projects. get_member_projects, Person.get_projects_sorted_by_contrib and now _contributions_sentence each filter on their own. A Person helper for "visible projects" that the first and third share would keep them from drifting. Fine to leave for a follow-up.

🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2

Review round 1 on PR 1469:
- Add MemberBioVisibilityTests, a DatabaseTestCase that renders the real
  member page for a person on a visible, a hidden (False) and a legacy
  NULL project, and asserts only the visible one is named. Fails with the
  filter removed.
- Rename the mock fixture so hidden projects sort before the visible one,
  killing the "count filtered, names from unfiltered list" mutant.
- Add a multi-project case that pins "2 projects:" with a hidden third.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68
jonfroehlich added a commit that referenced this pull request Dec 1, 2026
- New rule 6: poster and gallery thumbnail show the system's effect;
  STILL_AT puts that moment at frame 0.
- Safe area is 360x312 (poster on phones and the landing page are
  tighter than the project-page video); cite base.css for sizing.
- Hidden-project rule no longer assumes #1469 has merged; notes that
  /media/ uploads keep their filenames.
- Contact sheet writes sheet_%02d.jpg so long videos are fully covered.
- Size rule matches the script and explains the stale admin help text.
- Tool requirements; no personal paths in examples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68
@jonfroehlich

Copy link
Copy Markdown
Member Author

Fix round 1 for review 1 (on 2bcffdc). New head: 5299c5c193975e42c24469eba1448b4d739ae881. Only tests changed; bio_utils.py is as reviewed.

I reproduced each finding before changing anything, in a throwaway Postgres 16 with the project image.

1. should-fix: no DB-backed regression test. Fixed in 5299c5c. I added MemberBioVisibilityTests (a DatabaseTestCase in website/tests/test_bio_utils.py), adapted from the proposed test. It creates a person with a PhD position and roles on three projects: one visible, one is_visible=False, and one set to NULL with .update(). It then renders the real member page and checks that only the visible project is named. It passes at the new head and fails when bio_utils.py is reverted to master. It also fails on the nit 2 mutant.

2. nit: fixture order let a mutant survive. Fixed in 5299c5c. I reproduced it first: with the count filtered and the names taken from the unfiltered sorted list, all of the PR's original test_bio_utils.py passed (39 tests, OK). I renamed the fixtures so both hidden projects sort before the visible one ("Alpha Hidden", "Bravo Unset", "Zulu Public"). I also added test_hidden_projects_excluded_from_multi_project_count, which has two visible projects and one hidden one and asserts "2 projects:" and both visible names. Against the same mutant, the new file gives 3 failures: the renamed test, the new count test and the DB test.

3. nit: third copy of the visibility rule. Not changed in this PR. I agree a shared helper would be better. However, the only other caller with the same in-Python truthy check is views.member.get_member_projects. A helper used only by bio_utils would add a fourth spelling instead of removing one, so the helper only pays off if that view uses it too. I kept that refactor out of this bug-fix PR. Person.get_projects_sorted_by_contrib filters at the queryset level (is_visible=True), which excludes NULL just as the truthy check does, so the three copies agree on False and None today. The new DB test pins the bio's behaviour if they ever drift. A follow-up could add something like Person.get_visible_projects and have both get_member_projects and the bio use it.

Tests: the full suite passes locally (833 tests, OK, 8 skipped). CI on 5299c5c: test, e2e and a11y all pass (run).

🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5

@jonfroehlich jonfroehlich left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 5299c5c193975e42c24469eba1448b4d739ae881, range 2bcffdcc327e899bb2c9dcf46df414ffc6746143..5299c5c193975e42c24469eba1448b4d739ae881 (one commit, website/tests/test_bio_utils.py only). Review round 2, comment only.

No findings. Findings 1 and 2 from round 1 are closed, and I accept the answer on nit 3.

Round 1 findings

1. should-fix, no DB-backed regression test: closed. MemberBioVisibilityTests builds real Person, Position and ProjectRole rows (one visible project, one is_visible=False, one set to NULL with .update()), renders the member page and checks the whole response. It passes at this head and fails with bio_utils.py from origin/master. Its docstring also says it covers the projects grid; that holds: with the filter removed from views.member.get_member_projects and bio_utils.py left as in the PR, it fails. It passes when run alone, with the file reversed, and shuffled together with test_member_artifacts and test_page_metadata.

2. nit, fixture order let a mutant through: closed. Both hidden fixtures now sort before the visible one, and test_hidden_projects_excluded_from_multi_project_count pins "2 projects:" with a hidden third. The round 1 survivor (count filtered, names from the unfiltered sorted list) now fails three tests, as the reply says.

3. nit, third copy of the visibility rule: not changed, accepted. The reasoning holds: a helper only pays off if get_member_projects uses it too, and that refactor does not belong in a bug-fix PR. I confirmed the claim that the copies agree today: get_projects_sorted_by_contrib filters is_visible=True in the query, which drops NULL rows the same way the truthy check does. Follow-up material, not a condition on this PR.

Mutation results at this head

Each mutant replaced one source file; the tests were this head's test_bio_utils.py (41 tests, all pass unmutated).

Mutant Result Killed by
Filter removed (base bio_utils.py) killed DB test and 3 mock tests
is_visible is not False (None counts as visible) killed DB test and 1 mock test
is_visible is not None (False counts as visible) killed DB test and 3 mock tests
Filter inverted killed DB test and 9 mock tests
Names filtered, count from the unfiltered list killed DB test and 3 mock tests
Filter applied only when no project is visible killed DB test and 2 mock tests
Count filtered, names from the unfiltered sorted list (round 1 survivor) killed DB test and 2 mock tests
Single-project path correct, multi-project names unfiltered (new) killed the new count test
Single-project path correct, multi-project count unfiltered (new) killed the new count test
get_member_projects filter removed (new, view mutant) killed DB test
is_visible is True survives equivalent for a nullable boolean, not a gap

The two new multi-path mutants are killed only by test_hidden_projects_excluded_from_multi_project_count, so that test is doing work the others do not.

Did the change break anything

bio_utils.py is byte-identical to the file reviewed in round 1; the range touches only the test file. Full suite in a clean Postgres 16 with the project image: 833 tests, OK, 8 skipped. That matches the reply's count (831 in round 1 plus the 2 new tests).

🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant