Repository navigation
fix(accounting): search on a filter Paperless actually honours - #56
Merged
PhilippTheServer merged 1 commit intoAug 26, 2026
Merged
Conversation
GET /v1/admin/accounting/documents?query=... returned every document, whatever the search term. The router mapped query onto a Paperless filter named "text". Paperless has no such filter, and rather than rejecting an unknown parameter it ignores it — so the request succeeded, returned 200, and handed back the whole collection. Against 183 seeded documents, ?query=Barolo gave 183 instead of 25. The failure shape is the problem: an operator looking for one invoice gets a full result list that reads as a search matching a lot. Nothing errors. Moves the mapping into build_document_filters so it can be tested without a running Paperless, and pins every outgoing name against the set Paperless recognises — because a wrong name here never fails loudly, it just widens the result set. The existing test asserted the buggy value, so it is updated rather than deleted; it was locking in the defect. Also adds a limit to /v1/admin/analytics/storefront, matching the /products endpoint beside it. Its product_interest and top_paths were fixed at ten rows, which meant a caller could not reach anything outside the top ten — including, as it turned out, an integration test's own fixture once the shop had real traffic. Closes #55 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YY1ekLLeFLkAU2kvdQ8Ey4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #55 · found while seeding the new Paperless service with data
GET /v1/admin/accounting/documents?query=…returned every document, whatever the term.The router mapped
queryonto a Paperless filter namedtext. Paperless has no suchfilter, and ignores unknown parameters rather than rejecting them — so the request
succeeded, returned
200, and handed back the whole collection.Measured against 183 seeded documents:
An operator looking for one invoice gets a full result list that reads as a search matching
a lot. Nothing errors, nothing warns.
The fix
build_document_filtersmoves the mapping out of the endpoint so it can be tested without arunning Paperless, and
PAPERLESS_FILTERSpins every outgoing name against the setPaperless recognises — because a wrong name here never fails loudly, it just silently widens
the results.
The existing test asserted the buggy value (
{"text": "invoice"}), so it is updatedrather than deleted. It was locking the defect in.
Also here
/v1/admin/analytics/storefrontgains alimit, matching the/productsendpoint besideit. Its
product_interestandtop_pathswere fixed at ten rows with no way to ask formore — which surfaced when a shop with real traffic pushed an integration test's own fixture
SKU out of the top ten.
Verification
The tests catch the bug. Restoring
text: