Skip to content

[Bug]Fix model uri underscore#18849

Merged
B-Step62 merged 7 commits intomlflow:masterfrom
RohanRouth:fix-model-uri-underscore
Nov 20, 2025
Merged

[Bug]Fix model uri underscore#18849
B-Step62 merged 7 commits intomlflow:masterfrom
RohanRouth:fix-model-uri-underscore

Conversation

@RohanRouth
Copy link
Contributor

@RohanRouth RohanRouth commented Nov 14, 2025

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/18848/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/18848/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/18848/merge

Related Issues/PRs

Fixes #18926

#xxx

What 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?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests
image

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.
    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, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How 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" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

Yes should be selected for bug fixes, documentation updates, and other small changes. No should 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?
  • Minor release: a release that increments the second part of the version number (e.g., 1.2.0 -> 1.3.0).
    Bug fixes, doc updates and new features usually go into minor releases.
  • Patch release: a release that increments the third part of the version number (e.g., 1.2.0 -> 1.2.1).
    Bug fixes and doc updates usually go into patch releases.
  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

Signed-off-by: Rohan Routh <rohanrouth@gmail.com>
Signed-off-by: Rohan Routh <rohanrouth@gmail.com>
@github-actions github-actions bot added v3.6.1 area/evaluation MLflow Evaluation rn/bug-fix Mention under Bug Fixes in Changelogs. labels Nov 14, 2025
@RohanRouth RohanRouth changed the title Fix model uri underscore [Bug]Fix model uri underscore Nov 19, 2025
- 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>
@harupy harupy requested review from TomeHirata and Copilot November 20, 2025 00:38
Copy link
Member

@harupy harupy left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.urlparse with custom string splitting using split(":/", 1) and Python 3.10+ pattern matching
  • Added test cases for vertex_ai and azure_ai provider URIs
  • Removed the urllib.parse import 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>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Documentation preview for 611dea0 is available at:

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

@harupy harupy removed the request for review from TomeHirata November 20, 2025 01:05
@harupy harupy added the team-review Trigger a team review request label Nov 20, 2025
Copy link
Collaborator

@B-Step62 B-Step62 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the fix!

@B-Step62 B-Step62 added this pull request to the merge queue Nov 20, 2025
Merged via the queue into mlflow:master with commit df8e75d Nov 20, 2025
46 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/evaluation MLflow Evaluation rn/bug-fix Mention under Bug Fixes in Changelogs. team-review Trigger a team review request v3.6.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]make_judge model URI parser rejects valid LiteLLM providers (azure_ai, vertex_ai, <provider>/<model> format)

4 participants