test: label endpoint with asset type#1236
Conversation
Signed-off-by: fege <fmosca@redhat.com>
Signed-off-by: fege <fmosca@redhat.com>
…el_asset Signed-off-by: fege <fmosca@redhat.com>
|
The following are automatically added/executed:
Available user actions:
Supported labels{'/build-push-pr-image', '/cherry-pick', '/verified', '/wip', '/lgtm', '/hold'} |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughTests updated to handle MCP server labels separately from model labels: fixture now injects two labels into the ConfigMap; a utility gains an optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Security note (actionable): tests now inject labels into a ConfigMap without explicit validation of label fields — verify production code validating label names/values to avoid configuration injection or malformed metadata (CWE-20: Improper Input Validation). 🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/model_registry/model_catalog/conftest.py`:
- Around line 372-387: The fixture unconditionally extends
current_data["labels"] with new_labels which can introduce duplicates; update
the patching logic in this fixture to deduplicate before appending by comparing
each label's unique key (use tuple (label.get("name"), label.get("assetType"))),
build a set of existing keys from current_data["labels"], filter new_labels to
only those whose key is not present, and then extend current_data["labels"] with
the filtered list so duplicates are avoided.
In `@tests/model_registry/model_catalog/metadata/test_labels_endpoint.py`:
- Around line 66-76: The test currently only asserts that expected labels are
present but not that unexpected labels are absent; update the assertions around
get_labels_from_api and verify_labels_match to enforce asset-type isolation by
(1) asserting that none of mcp_expected_labels appear in api_labels (default
without asset_type) and (2) asserting that none of model_expected_labels appear
in mcp_api_labels (when asset_type="mcp_servers"), using the existing
model_expected_labels and mcp_expected_labels lists to drive these negative
checks; keep using get_labels_from_api and verify_labels_match for positive
checks but add explicit absence assertions (e.g., ensuring no label with
assetType == "mcp_servers" exists in api_labels and no label with assetType !=
"mcp_servers" exists in mcp_api_labels).
In `@tests/model_registry/model_catalog/metadata/utils.py`:
- Around line 462-463: Reject unsupported asset_type values before calling
execute_get_command: validate the asset_type argument against an allowlist
(e.g., the expected asset types used in tests), and if asset_type is not None
and not in that allowlist, raise an explicit error (ValueError or
AssertionError) to fail fast; then construct params as before (params =
{"assetType": asset_type} if asset_type is not None else None) and call
execute_get_command(url=url, headers=headers, params=params). This validation
should be added near the use of asset_type/params in the same helper
(referencing the asset_type variable and execute_get_command) so typos like
"mcp_server" are caught before the request is issued.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 63b329a5-7a5e-44e8-b903-28150c33c27c
📒 Files selected for processing (3)
tests/model_registry/model_catalog/conftest.pytests/model_registry/model_catalog/metadata/test_labels_endpoint.pytests/model_registry/model_catalog/metadata/utils.py
tests/model_registry/model_catalog/metadata/test_labels_endpoint.py
Outdated
Show resolved
Hide resolved
…el_asset Signed-off-by: fege <fmosca@redhat.com>
Signed-off-by: fege <fmosca@redhat.com>
|
Status of building tag latest: success. |
Signed-off-by: fege <fmosca@redhat.com> Signed-off-by: Shehan Saleem <ssaleem@redhat.com>
Pull Request
Summary
Related Issues
How it has been tested
Additional Requirements
Summary by CodeRabbit