Skip to content

1973 bug edit superhashlist bug in hashlist datasource#2057

Open
prettyaveragecoder wants to merge 2 commits intodevfrom
1973-bug-edit-superhashlist-bug-in-hashlist-datasource
Open

1973 bug edit superhashlist bug in hashlist datasource#2057
prettyaveragecoder wants to merge 2 commits intodevfrom
1973-bug-edit-superhashlist-bug-in-hashlist-datasource

Conversation

@prettyaveragecoder
Copy link
Copy Markdown

Summary

Fix missing meta.page.total_elements in getOneResource for to-many includes.

Frontend got a TypeError when editing a superhashlist because
response.meta.page.total_elements was undefined in the API response.

Changes

  • AbstractBaseAPI.php: getOneResource now returns meta.page.total_elements
    when the request includes a to-many relationship (e.g. include=hashlists)

Known limitation

The current implementation counts total expanded objects across all to-many
relationships in a single value. This works correctly today because no
endpoint includes multiple to-many relationships simultaneously. If that
changes in the future, total_elements may return an incorrect combined count
and will need to be revisited.

Test

Added test_superhashlist_edit_returns_meta_page_total_elements in
test_hashlist.py to verify that meta.page.total_elements is returned
correctly when fetching a superhashlist with include=hashlists.

The test makes a direct HTTP request instead of using the hashtopolis
Python library, because the library only returns the deserialized data
object (response['data']) and discards the meta field. By using
requests.get() directly we get the raw JSON:API response and can assert
that meta.page.total_elements exists and has the correct value.

@prettyaveragecoder prettyaveragecoder requested a review from s3inlc May 7, 2026 13:10
@jessevz
Copy link
Copy Markdown
Contributor

jessevz commented May 7, 2026

How does this work when you are included multiple to many expands? Wont the last always overwrite the result?

Personally I would say to solve this is to not load a pagesize for this in the frontend since pagination is not possible for the included section anyway

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.

2 participants