[Bug]Fix model uri underscore#18849
Merged
B-Step62 merged 7 commits intomlflow:masterfrom Nov 20, 2025
Merged
Conversation
Signed-off-by: Rohan Routh <rohanrouth@gmail.com>
Signed-off-by: Rohan Routh <rohanrouth@gmail.com>
- Replace if/else logic with match statement for cleaner code - Add comment explaining why urllib.parse.urlparse is not used - Move tests from mlflow/metrics/genai/ to tests/metrics/genai/ - Parameterize test_parse_model_uri for better test coverage - Add test cases for providers with underscores (vertex_ai, azure_ai) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where model URIs with provider names containing underscores (e.g., vertex_ai, azure_ai) were incorrectly rejected. The issue occurred because urllib.parse.urlparse treats underscores as invalid in URI schemes per RFC 3986, causing the entire URI to be placed in the path component rather than being split into scheme and path.
Key Changes:
- Replaced
urllib.parse.urlparsewith custom string splitting usingsplit(":/", 1)and Python 3.10+ pattern matching - Added test cases for
vertex_aiandazure_aiprovider URIs - Removed the
urllib.parseimport from the module
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mlflow/metrics/genai/model_utils.py | Reimplemented _parse_model_uri to use string splitting and pattern matching instead of urllib.parse.urlparse, enabling support for provider names with underscores |
| tests/metrics/genai/test_model_utils.py | Refactored test into parameterized format and added test cases for vertex_ai and azure_ai providers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Contributor
|
Documentation preview for 611dea0 is available at: More info
|
B-Step62
approved these changes
Nov 20, 2025
Collaborator
B-Step62
left a comment
There was a problem hiding this comment.
LGTM, thank you for the fix!
Tian-Sky-Lan
pushed a commit
to Tian-Sky-Lan/mlflow
that referenced
this pull request
Nov 24, 2025
Signed-off-by: Rohan Routh <rohanrouth@gmail.com> Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> Co-authored-by: harupy <17039389+harupy@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Tian Lan <sky.blue266000@gmail.com>
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.
🛠 DevTools 🛠
Install mlflow from this PR
For Databricks, use the following command:
Related Issues/PRs
Fixes #18926
#xxxWhat changes are proposed in this pull request?
This PR fixes a bug in _parse_model_uri where provider names containing underscores (e.g., vertex_ai, azure_ai) are rejected due to reliance on urllib.parse.urlparse.
Because MLflow model URIs are not URLs and do not follow RFC 3986 scheme rules, urlparse incorrectly places the entire URI into the path component, causing valid URIs to fail with:
Malformed model uri ':/'
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
Fixes a bug where valid model URIs using providers like vertex_ai:/gemini-2.0 were incorrectly rejected.
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.