Skip to content

[BUG] mlflow models serve fails with HTTP 500 instead of 400 on bad input #4897

@mmaitre314

Description

@mmaitre314

Thank you for submitting an issue. Please refer to our issue policy for additional information about bug reports. For help with debugging your code, please refer to Stack Overflow.

Please fill in this bug report template to ensure a timely and thorough response.

Willingness to contribute

The MLflow Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the MLflow code base?

  • Yes. I can contribute a fix for this bug independently.
  • Yes. I would be willing to contribute a fix for this bug with guidance from the MLflow community.
  • No. I cannot contribute a bug fix at this time.

System information

  • Have I written custom code (as opposed to using a stock example script provided in MLflow): yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): windows 10
  • MLflow installed from (source or binary): binary
  • MLflow version (run mlflow --version): 1.20.2
  • Python version: 3.8
  • npm version, if running the dev UI: N/A
  • Exact command to reproduce:
    • Start server: mlflow models serve -m runs:/5f8aee52fcb442388368af4da658b398/model --no-conda
    • Submit an inference request: curl -i -X POST -d "{\"data\":0.0199132142]}" -H "Content-Type: application/json" http://localhost:5000/invocations

Describe the problem

Describe the problem clearly here. Include descriptions of the expected behavior and the actual behavior.

Submitting an inference requests to the MLFlow model server with invalid content returns HTTP error 500 'Internal Server Error' instead of HTTP error 400 'Bad Request'. This prevents proper error handling on the client side and blocks REST API fuzzing.

Ex:

curl -i -X POST -d "{\"data\":0.0199132142]}" -H "Content-Type: application/json" http://localhost:5000/invocations
HTTP/1.1 500 INTERNAL SERVER ERROR
Content-Length: 901
Content-Type: application/json
Date: Wed, 13 Oct 2021 22:16:44 GMT
Server: mlflow

{"error_code": "MALFORMED_REQUEST", "message": "Failed to parse input from JSON. Ensure that input is a valid JSON formatted string.", "stack_trace": "Traceback (most recent call last):\n  File \"C:\\Source\\local_training_mlflow_project\\.venv\\lib\\site-packages\\mlflow\\pyfunc\\scoring_server\\__init__.py\", line 81, in infer_and_parse_json_input\n    decoded_input = json.loads(json_input)\n  File \"C:\\Users\\mmaitre\\Anaconda3\\lib\\json\\__init__.py\", line 357, in loads\n    return _default_decoder.decode(s)\n  File \"C:\\Users\\mmaitre\\Anaconda3\\lib\\json\\decoder.py\", line 337, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File \"C:\\Users\\mmaitre\\Anaconda3\\lib\\json\\decoder.py\", line 353, in raw_decode\n    obj, end = self.scan_once(s, idx)\njson.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 21 (char 20)\n"}

Code to reproduce issue

Provide a reproducible test case that is the bare minimum necessary to generate the problem.'

curl -i -X POST -d "{\"data\":0.0199132142]}" -H "Content-Type: application/json" http://localhost:5000/invocations

Other info / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

What component(s), interfaces, languages, and integrations does this bug affect?

Components

  • area/artifacts: Artifact stores and artifact logging
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages
  • area/examples: Example code
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/projects: MLproject format, project running backends
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/server-infra: MLflow Tracking server backend
  • area/tracking: Tracking Service, tracking client APIs, autologging

Interface

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/docker: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
  • area/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registry
  • area/windows: Windows support

Language

  • language/r: R APIs and clients
  • language/java: Java APIs and clients
  • language/new: Proposals for new client languages

Integrations

  • integrations/azure: Azure and Azure ML integrations
  • integrations/sagemaker: SageMaker integrations
  • integrations/databricks: Databricks integrations

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/scoringMLflow Model server, model deployment tools, Spark UDFsbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions