Skip to content

fix(core): propagate filterQuery in GetServingEnvironments and GetModelArtifacts - #3220

Merged
google-oss-prow[bot] merged 1 commit into
kubeflow:mainfrom
rishabhsai:fix-filterquery-serving-environments-model-artifacts
Sep 22, 2026
Merged

google-oss-prow[bot] merged 1 commit into
kubeflow:mainfrom
rishabhsai:fix-filterquery-serving-environments-model-artifacts

Conversation

@rishabhsai

Copy link
Copy Markdown
Contributor

Description

filterQuery is accepted and then dropped on GET /api/model_registry/v1/serving_environments and GET /api/model_registry/v1/model_artifacts (and their v1alpha3 twins), so both endpoints return the full unfiltered list and an unparseable filter comes back as a success instead of a bad request.

The parameter reaches core and is lost there. GetServingEnvironments at internal/core/serving_environment.go:105 and GetModelArtifacts at internal/core/artifact.go:598 copy PageSize, OrderBy, SortOrder and NextPageToken into models.Pagination but not FilterQuery. Serving environments have a second cause: ServingEnvironmentListOptions in internal/db/models/serving_environment.go:3 does not implement GetRestEntityType, so the listOptions.(FilterApplier) assertion in internal/platform/db/repository/generic_repository.go:50 fails and ApplyFilterQuery skips the filter even once the field is set. Adding the two assignments and the missing method is the whole change.

#3207 and #3208 found and fixed the same defect on /inference_services and /serves, two of the four list endpoints that declare filterQuery in the OpenAPI specs, and #3207 stated the others were already correct; the remaining two are fixed here. DocArtifactListOptions, DataSetListOptions, MetricListOptions and ParameterListOptions also lack GetRestEntityType, but no endpoint that accepts filterQuery reaches them (GetArtifacts uses ArtifactListOptions, which has it), so they are left alone.

Fixes #3219

How Has This Been Tested?

Two new tests shaped after TestGetInferenceServicesWithFilterQuery from #3208: TestGetServingEnvironmentsWithFilterQuery in internal/core/serving_environment_test.go and TestGetModelArtifactsWithFilterQuery in internal/core/artifact_test.go. Each covers name equality, externalId, LIKE, AND and OR, invalid syntax, a filter matching nothing, and a filter combined with pageSize=1 over two pages. The existing TestArtifactFilterQuery/GetModelArtifacts with experimentId filter asserted only GreaterOrEqual(len(items), 1) under a note calling the leakage "the current behavior"; it now asserts the exact single match.

Before the change, go test ./internal/core/ -run FilterQuery -count=1:

--- FAIL: TestGetServingEnvironmentsWithFilterQuery/Filter_by_exact_name
    Error:    Not equal: expected: 1, actual: 4
    Messages: filterQuery "name = 'prod-serving-env'": expected 1 items, got 4 (filter may be silently ignored)
--- FAIL: TestGetServingEnvironmentsWithFilterQuery/Invalid_filter_syntax_returns_error
    Error:    An error is expected but got nil.
--- FAIL: TestGetModelArtifactsWithFilterQuery/Filter_by_exact_name
    Error:    Not equal: expected: 1, actual: 4
    Messages: filterQuery "name = 'fraud-model'": expected 1 items, got 4 (filter may be silently ignored)
--- FAIL: TestArtifactFilterQuery/GetModelArtifacts_with_experimentId_filter
    Error:    "[...]" should have 1 item(s), but has 2
FAIL	github.com/kubeflow/hub/internal/core	15.180s

After the change, same command:

--- PASS: TestArtifactFilterQuery (2.08s)
--- PASS: TestGetModelArtifactsWithFilterQuery (0.82s)
--- PASS: TestGetServingEnvironmentsWithFilterQuery (0.64s)
--- PASS: TestGetInferenceServicesWithFilterQuery (0.76s)
--- PASS: TestGetServeModelsWithFilterQuery (0.74s)
ok  	github.com/kubeflow/hub/internal/core	23.597s

make test, make vet, make lint and make build all pass locally on Go 1.26.1 with the testcontainers MySQL 8.3 and PostgreSQL databases. Reverting the three source edits while keeping the tests makes both new tests fail again, and reverting only the GetRestEntityType addition makes TestGetServingEnvironmentsWithFilterQuery fail on its own, so each edit is load bearing.

Merge criteria:

  • All the commits have been signed-off (To pass the DCO check)

  • The commits have meaningful messages

  • Automated tests are provided as part of the PR for major new functionalities; testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).

  • The developer has manually tested the changes and verified that the changes work.

  • Code changes follow the kubeflow contribution guidelines.

  • For first time contributors: Please reach out to the Reviewers to ensure all tests are being run, ensuring the label ok-to-test has been added to the PR.

This is my first PR here, so a reviewer will need to add the ok-to-test label for CI to run.

If you have UI changes

  • The developer has added tests or explained why testing cannot be added.
  • Included any necessary screenshots or gifs if it was a UI change.
  • Verify that UI/UX changes conform the UX guidelines for Kubeflow.

…elArtifacts

Both methods built the repository pagination options without copying
FilterQuery, so the parameter was dropped and the endpoints returned the
full unfiltered list. ServingEnvironmentListOptions also had no
GetRestEntityType, so ApplyFilterQuery skipped it even once the field was
set. This is the sibling of kubeflow#3208, which covered the other two list
endpoints.

Assisted-by: Claude
Signed-off-by: Rishabh <rishabhsaiv@gmail.com>

@vjkumar2756 vjkumar2756 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rishabhsai
Code looks great. It successfully fixes the filterQuery issue for model artifacts & serving environments with solid unit tests.
NIce OnE

@pboyd

pboyd commented Sep 22, 2026

Copy link
Copy Markdown
Member

@rishabhsai, thanks for the PR.

/lgtm
/approve

@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pboyd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow
google-oss-prow Bot merged commit 3229255 into kubeflow:main Sep 22, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

filterQuery is ignored on GET /serving_environments and GET /model_artifacts

3 participants