Skip to content

feat(auditor): add filtering to target and config list endpoints (AIRCORE-387)#182

Open
maxdubrinsky wants to merge 2 commits into
mainfrom
aircore-387-auditor-filters/md
Open

feat(auditor): add filtering to target and config list endpoints (AIRCORE-387)#182
maxdubrinsky wants to merge 2 commits into
mainfrom
aircore-387-auditor-filters/md

Conversation

@maxdubrinsky
Copy link
Copy Markdown
Contributor

@maxdubrinsky maxdubrinsky commented Jun 4, 2026

What

The auditor plugin's target and config list endpoints previously supported only page / page_size / sort. This adds query filtering through the standard plugin idiom.

  • New TargetFilter (type, model, description, project, created_at, updated_at) and ConfigFilter (description, project, created_at, updated_at) in api/v2/schemas.py — both NemoFilter subclasses (extra="forbid"), with DatetimeFilter range support on the timestamps.
  • list_targets / list_configs now take a filter[...] dependency (make_filter_obj_dep) and forward filter_obj to entity_client.list.
  • A small auditor-local _filters.make_filter_dep wrapper maps the raw pydantic ValidationError raised on an unknown filter key to HTTP 422 — the platform registers no handler for it, so the bare dependency would surface a 500. Shared infra is untouched.

Compatibility

Additive. With no filter the call is identical to before; page / page_size / sort and the response shape are unchanged (a filter echo key is added). Misspelled filter keys now return 422 (intended).

Tests

15 new tests (8 target / 7 config): per-field filtering, project narrowing, created_at $gte/$lte ranges, 422 on unknown key, and an empty-filter regression. Plugin suite green (40 passed).

Remaining before merge

Run make refresh-openapi to regenerate plugins/nemo-auditor/openapi/openapi.yaml (spec-from-Pydantic; no Stainless — auditor ships hand-written SDK resources).

AIRCORE-387

Summary by CodeRabbit

  • New Features
    • Add filtering to config and target listing endpoints, including date-range support; filters are exposed in OpenAPI and echoed in list responses.
  • Bug Fixes
    • Unknown or misspelled filter keys now return HTTP 422 with clearer validation details.
  • Tests
    • New tests for config and target list filtering: parameter forwarding, range parsing, error handling, and response shape.

@maxdubrinsky maxdubrinsky requested review from a team as code owners June 4, 2026 17:57
@maxdubrinsky maxdubrinsky requested a review from parkanzky June 4, 2026 17:59
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dc40d0cd-2927-425b-b071-20228331c72e

📥 Commits

Reviewing files that changed from the base of the PR and between 55255da and d5f5c2c.

📒 Files selected for processing (1)
  • plugins/nemo-auditor/openapi/openapi.yaml

📝 Walkthrough

Walkthrough

Adds query filtering to the targets and configs list endpoints. New filter schemas define optional fields for type, model, description, project, and timestamp ranges. A dependency factory validates filter payloads and converts Pydantic errors to HTTP 422. Both endpoints inject filter dependencies, forward converted filter objects to the entity client, and echo filters in responses. Tests verify parameter forwarding, range parsing, validation errors, and response structure.

Changes

Query filtering for targets and configs list endpoints

Layer / File(s) Summary
Filter schemas and dependency factory
plugins/nemo-auditor/src/nemo_auditor/api/v2/schemas.py, plugins/nemo-auditor/src/nemo_auditor/api/v2/_filters.py
TargetFilter and ConfigFilter models extend NemoFilter with optional fields for filtering by type, model, description, project, and created_at/updated_at ranges. make_filter_dep wraps async validation and converts ValidationError to HTTP 422 with error details.
Target list endpoint with filtering
plugins/nemo-auditor/src/nemo_auditor/api/v2/targets.py
list_targets accepts injected TargetFilter dependency via _target_filter_dep, converts it to a dict for entity_client.list as filter_obj, includes OpenAPI extra params for filter schema documentation, and echoes the filter in the response payload.
Config list endpoint with filtering
plugins/nemo-auditor/src/nemo_auditor/api/v2/configs.py
list_configs accepts injected ConfigFilter dependency via _config_filter_dep, converts it to a dict for entity_client.list as filter_obj, includes OpenAPI extra params for filter schema documentation, and echoes the filter in the response payload.
OpenAPI parameter and schema updates
plugins/nemo-auditor/openapi/openapi.yaml
Adds deepObject filter query parameters to List Targets and List Configs operations and introduces ConfigFilter, TargetFilter, and DatetimeFilter component schemas documenting supported operators and shapes.
Filtering tests
plugins/nemo-auditor/tests/test_api_targets.py, plugins/nemo-auditor/tests/test_api_configs.py
TestListTargetsFiltering and TestListConfigsFiltering verify filter parameters are forwarded as filter_obj, created_at ranges with $gte/$lte are parsed correctly, unknown filter keys return HTTP 422, missing filters forward None, and responses include data, pagination, sort, and echoed filter.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding filtering to target and config list endpoints, which is the primary focus across multiple files in this changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch aircore-387-auditor-filters/md

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Suite Lines Covered Line Rate Branch Rate
Unit Tests 18715/24765 75.6% 62.0%
Integration Tests 11997/23529 51.0% 26.2%

…CORE-387)

Add optional deepObject filter support to the auditor target and config
list endpoints, mirroring the example/agents plugin idiom
(make_filter_obj_dep + entity_client.list(filter_obj=...)).

- schemas.py: add TargetFilter (type, model, description, project,
  created_at/updated_at) and ConfigFilter (description, project,
  created_at/updated_at), both subclassing NemoFilter (extra="forbid").
- targets.py / configs.py: parse filter params, forward as filter_obj,
  echo the filter back in the response, and register the filter schema
  via generate_openapi_extra_params. page/page_size/sort unchanged; the
  raw-dict response shape is preserved and only gains a "filter" key.
- _filters.py: thin make_filter_dep wrapper that converts the
  pydantic.ValidationError raised on an unknown filter key into a 422
  (the bare make_filter_obj_dep dependency otherwise surfaces a 500).

Purely additive: omitting filter params reproduces the prior behavior.

Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
@maxdubrinsky maxdubrinsky force-pushed the aircore-387-auditor-filters/md branch from 3217320 to 55255da Compare June 4, 2026 18:46
…E-387)

Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
page: int = Query(default=1, ge=1),
page_size: int = Query(default=20, ge=1, le=100),
sort: str = Query(default="-created_at"),
filter: TargetFilter = Depends(_target_filter_dep),
Copy link
Copy Markdown

@parkanzky parkanzky Jun 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to shadow the filter python built-in. If that's the only way to get the user-facing API we want that may be ok, but it would be best to not shadow built-ins.

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