AAP-101932 XLAB Add POST report query endpoints with select_all/exclude #547
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #547"
general
weight: 0.35
kcagran
AAP-101932 XLAB Add POST report query endpoints with select_all/exclude
Description
parameters for the report filters (select all, search, exclude).
labels, organizations or projects) the URL exceeds the length limits of the gateway/proxies and the request fails.
The UI also cannot express "all except N" or "everything matching a search" without listing every ID. The design
was agreed in spike AAP-101273.
- POST query endpoints in
DashboardReportViewSet. They return the same data as the matching GET endpoints:-
POST /dashboard_reports/report/query/→GET report/-
POST /dashboard_reports/report/details/query/→GET report/details/-
POST /dashboard_reports/report/export/query/→GET report/export/(CSV)Filters go in the JSON body and are validated by
ReportQuerySerializer. Pagination and ordering stay in thequery string (
page,page_size,order_by). These are separatequeryactions because POST on the list routeis reserved for create.
- Shared parameter source:
CustomReportFilter, the filter option helpers and the period parsing read theirvalues from a single source. POST query actions use
request.dataand GET usesrequest.query_params. Both gothrough the same code path, so they return identical results.
- Permissions: new
apps/core/permissions.py::IsSystemAdminOrAuditorReadQuery. DAB'sIsSystemAdminOrAuditorallows platform auditors only on safe methods, which would lock them out of the POST query endpoints. A view
lists its side-effect-free actions in
read_only_query_actions, and those actions need only the viewpermission. Every other action keeps the parent behaviour, so writes stay admin-only.
- Selection parameters: for each filter field (
template,label,organization,project), on both GET andPOST:
| Parameter | Meaning |
|---|---|
|
<field>=<id>(existing) | explicitly selected IDs ||
select_all_<field>=true| every item, the same as no filter on that field ||
search_<field>=<term>| every item whose name matches the term ||
excluded_<field>=<id>| explicitly deselected IDs ||
excluded_search_<field>=<term>| deselected: every item whose name matches the term |- With
select_all, every job is kept, then excluded IDs and excluded search matches are removed.- Without
select_all, jobs matching the selected IDs or search matches are kept, then the exclusions areremoved.
-
select_allincludes historical runs of deleted items and rows with NULL IDs, the same as no filter.- Labels: excluding label X excludes every job that has X, even if it also has a selected label Y.
- Search terms are resolved on every request, so a saved or shared selection also picks up items created later.
Their number and length are capped on GET and POST alike (100 terms, 512 characters each; 400 otherwise).
The terms of all fields are validated before the AWX connection is opened.
- No writes from the query actions: the report cost calculation reads the subscription cost with the new
SubscriptionCost.get_or_default(), which returns the existing row or unsaved defaults. On an empty table thePOST query actions use the same default values as GET but never create the row. GET is unchanged.
- OpenAPI: the request body and the selection parameters are documented. The checked-in schema files
(
tools/openapi-schema/metrics-service.{yaml,json}) are regenerated withtools/generate-openapi.sh.Type of Change
Self-Review Checklist
Testing Instructions
Prerequisites
JobData) synced from AWX.Steps to Test
1. Run the unit tests:
uv run pytest tests/unit/dashboard_reports/test_report_query_endpoints.py tests/unit/dashboard_reports/test_report_selection.py tests/unit/core/test_permissions.py2. As an admin, call
GET /api/v1/dashboard_reports/report/?template=1&template=2andPOST /api/v1/dashboard_reports/report/query/with the body{"template": [1, 2]}, and compare the responses.Repeat for
report/details/andreport/export/.3. Call
POST .../report/query/with{"select_all_template": true, "excluded_template": [1]}and check that alltemplates except 1 are included.
4. Call
POST .../report/query/with{"search_template": ["deploy"]}and check that only templates whose namematches "deploy" are included.
5. Repeat step 2 as the platform auditor and as the regular user.
6. Call
GET .../report/details/with 101search_templatevalues, or one value longer than 512 characters.7. On a database without a subscription cost row (
SubscriptionCost.objects.all().delete()), call the three POSTquery endpoints and check
SubscriptionCost.objects.exists().Expected Results
label.
403 everywhere.
are accepted.
SubscriptionCost.objects.exists()staysFalse.Additional Context
POST endpoints including CSV export): 13/13 checks passed.
xlab-dashboard-filters-select-all(ansible-ui). The UI never sends an empty list(an empty selection means no filter) and builds
page/page_size/order_byitself.next/previouspagination links do not include the gateway prefix. This isthe same on GET.
Segment server), ruff clean, CI green.
Required Actions
<!-- Check if changes require work in other areas -->
<!-- Remove section if no external actions needed -->
<!-- API docs, feature docs, deployment guides -->
<!-- Specify repos: django-ansible-base, eda-server, etc. -->
<!-- CI/CD, installer updates, new services -->
<!-- UI team, platform services, infrastructure -->
<!-- Reference blocking PRs/MRs with brief context -->
Screenshots/Logs
<!-- Add if relevant to demonstrate the changes -->