Skip to content

fix(notes): visible_notes handles a paginated list, not just a queryset - #15593

Merged
Maffooch merged 3 commits into
bugfixfrom
fix/visible-notes-handles-paginated-list
Aug 10, 2026
Merged

fix(notes): visible_notes handles a paginated list, not just a queryset#15593
Maffooch merged 3 commits into
bugfixfrom
fix/visible-notes-handles-paginated-list

Conversation

@devGregA

@devGregA devGregA commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Description

dojo/notes/helper.py::visible_notes() assumed its input is always a queryset and called .filter() on it. But NoteSerializer.Meta.list_serializer_class = VisibleNotesSerializer, and under DRF pagination the list serializer's to_representation receives the page as a plain list — the queryset is evaluated into a page before serialization. VisibleNotesSerializer only special-cases a Manager, so it passed that list straight to visible_notes(), which then did list.filter(...):

AttributeError: 'list' object has no attribute 'filter'   ->   HTTP 500 on the notes read

Superusers skip the .filter() branch (they receive everything), so this only surfaced for non-superusers and the no-user report-rendering path — on any paginated notes read.

Fix

Make visible_notes() apply the same visibility rule whether it receives a queryset or an already-evaluated iterable:

  • queryset / manager → keep the existing ORM .filter(...),
  • an already-evaluated page (a list) → apply the identical rule in Python.

visible_notes is the single choke-point every read path (API + UI) shares, so this needs no changes at any call site, and the UI callers (which pass querysets) are unaffected.

Tests

Added unittests/test_apiv2_note_visibility.py::NoteVisibilityTest::test_helper_accepts_an_already_evaluated_list, which passes a list (exactly what pagination hands the serializer) for author / colleague / superuser / no-user and asserts the same visibility the queryset path already enforces. It fails before this change with AttributeError: 'list' object has no attribute 'filter' and passes after.

Regression introduced with the private-note visibility work (VisibleNotesSerializer / visible_notes); the existing helper tests only exercised the queryset form, so the paginated-list path went uncovered.

NoteSerializer.Meta.list_serializer_class = VisibleNotesSerializer, and under
DRF pagination the list serializer's to_representation receives the page as a
plain list (the queryset is evaluated before serialization). VisibleNotesSerializer
only special-cases a Manager, so it passed the list straight to visible_notes(),
which then called list.filter():

    AttributeError: 'list' object has no attribute 'filter'  ->  HTTP 500

Superusers skip the .filter() branch, so this only surfaced for non-superusers
(and the no-user report path), on any paginated notes read.

Apply the same visibility rule whether visible_notes() is given a queryset or an
already-evaluated iterable: keep the ORM filter for querysets, filter in Python
for a list. visible_notes is the single choke-point every read path shares, so
there are no call-site changes.

Regression test: NoteVisibilityTest.test_helper_accepts_an_already_evaluated_list
passes a list (as pagination does) for author / colleague / superuser / no-user
and asserts the same rule the queryset path already enforces.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Maffooch and others added 2 commits August 10, 2026 08:58
Move the multi-line docstring summary to the second line so ruff's
D213 (multi-line-summary-second-line) passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CyqgbQCF7dVVMxMXaoEaY
…andles-paginated-list

# Conflicts:
#	dojo/notes/helper.py
@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@Maffooch
Maffooch added this pull request to the merge queue Aug 10, 2026
Merged via the queue into bugfix with commit 53a1d83 Aug 10, 2026
48 checks passed
@Maffooch
Maffooch deleted the fix/visible-notes-handles-paginated-list branch August 10, 2026 15:41
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.

3 participants