fix(cli): reject filter flags the resource does not support - #26
Merged
Conversation
The list factory sent search, record_status, start_date and end_date to every resource. Filter schemas in the public API declare only their own fields and django-ninja drops the rest before validation, so unsupported flags returned unfiltered results with exit code 0. Each resource now declares the filter flags its /public/v2 list endpoint actually exposes, verified against the v2 OpenAPI schema. Flags outside that set are removed from the command, aliases included, so passing one exits non-zero and names the flag and the resource. The argument is required, so a new resource cannot inherit a wrong default. Also: - contracts name their status filter `status`, not `record_status`; the CLI mapped --status to record_status, which the API ignored while the real filter stayed unreachable. Fixed assets declare both and keep the record_status mapping, which is what --status means everywhere else. - expose company/customer/vendor on the eleven resources that support them but were not offering them.
Warkanlock
commented
Sep 1, 2026
Warkanlock
left a comment
Contributor
Author
There was a problem hiding this comment.
Additional Comments
The following comments reference lines outside the diff and are included here:
💡 src/dualentry_cli/main.py:20
Verdict: Filter gating is correctly assigned to all 30+ resources and matches test expectations in test_filter_gating.py. The new status_param override for contracts (line 88) correctly maps --status to the status query param instead of record_status. All make_resource_app() calls now supply a filters set. Rejection of unsupported flags is tested (lines 97–127 of the test file). Residual: the diff cites the v2 OpenAPI schema as the source of truth for each resource's filters set, but does not link to a live schema check—manual updates could drift if the API changes.
Keep both make_list_command_cls (EOPS-369) and _MAX_PAGES (EOPS-378) after #23 landed.
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.
Summary
--start-date/--end-date/--statuswere sent on every list. The API drops unknown query params, socustomers list --start-date 2025-01-01returned unfiltered results with exit 0.Fixes EOPS-369
Changes
tests/test_filter_gating.pyTest plan
uv run pytest)uv run ruff check .)customers list --start-date 2025-01-01exits 2 and names the flagcompanies list --status postedexits 2invoices list --start-date 2025-01-01still filterscustomers list --status postedstill works