Skip to content

fix: reject blank model names before registration - #2607

Open
loyce-cheng wants to merge 1 commit into
SeldonIO:masterfrom
loyce-cheng:bug/model-name-validation-2382
Open

loyce-cheng wants to merge 1 commit into
SeldonIO:masterfrom
loyce-cheng:bug/model-name-validation-2382

Conversation

@loyce-cheng

Copy link
Copy Markdown

Description

When a model is configured through environment variables without MLSERVER_MODEL_NAME, it can be loaded successfully under an empty name and cannot be addressed through the model API. Reject empty and whitespace-only names before model initialisation, load hooks, or registry changes.

Name validation happens at registration so that file-based loading can still infer a missing or empty name from its directory, preserving the behaviour introduced in #190. ModelSettings.name remains optional until that resolution has taken place; valid names are not modified.

Changes Made

  • Add InvalidModelName, an MLServerError with status 422 and configuration guidance.
  • Validate the resolved name at the start of MultiModelRegistry.load().
  • Cover invalid names, environment-only configuration, absence of loading side effects, and directory-name fallback; update both model-settings reference pages.

Related Issues

Fixes #2382.

Validation

  • Reproduced seven failing regression cases on unchanged production code, including the reported successful empty-name load.
  • 61 related settings, registry, repository-loading and repository-handler tests passed on Python 3.12.14 / Windows, using a local launcher for the upstream SIGQUIT import and non-uvloop event-loop-policy fixture issues. These launcher changes are not part of this PR.
  • Black, Flake8, git diff --check, and mypy on the two changed production modules with --follow-imports=silent passed.
  • Full core mypy reports the same nine diagnostics on this branch and an untouched upstream checkout: Windows signal constants and existing CORS/Starlette type mismatches.

Checklist

  • Code follows the project's style guidelines
  • Related tests listed above pass with the documented local launcher
  • Documentation is updated
  • Code is reviewed by at least one other team member
  • Behaviour change is documented: unresolved blank names now fail at registration

Additional Notes

The real-server repository test is blocked locally by Windows add_signal_handler support. Linux process/signal behaviour, the full runtime suites and the Python 3.9–3.12 CI matrix have not been validated locally.

This branch has not been deployed

No deployments
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.

No validation for model name field - allows empty string

1 participant