{"record":{"id":"8e2d71fae0f178dc","repo":"mlflow/mlflow","slug":"static-prefix-should-not-end-with-a","errorCode":null,"errorMessage":"--static-prefix should not end with a '/'.","messagePattern":"--static-prefix should not end with a '/'\\.","errorType":"validation","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"mlflow/cli/__init__.py","lineNumber":363,"sourceCode":"            \"Security middleware parameters (--allowed-hosts, --cors-allowed-origins, \"\n            \"--disable-security-middleware) are only supported with \"\n            \"the default uvicorn server. They cannot be used with --gunicorn-opts or \"\n            \"--waitress-opts. To use security features, run without specifying a server \"\n            \"option (uses uvicorn by default) or explicitly use --uvicorn-opts.\"\n        )\n\n\ndef _validate_static_prefix(ctx, param, value):\n    \"\"\"\n    Validate that the static_prefix option starts with a \"/\" and does not end in a \"/\".\n    Conforms to the callback interface of click documented at\n    http://click.pocoo.org/5/options/#callbacks-for-validation.\n    \"\"\"\n    if value is not None:\n        if not value.startswith(\"/\"):\n            raise UsageError(\"--static-prefix must begin with a '/'.\")\n        if value.endswith(\"/\"):\n            raise UsageError(\"--static-prefix should not end with a '/'.\")\n        if \"{\" in value or \"}\" in value:\n            raise UsageError(\"--static-prefix must not contain '{' or '}'.\")\n    return value\n\n\n@cli.command(short_help=\"Run the MLflow tracking server (UI + REST API).\")\n@click.pass_context\n@click.option(\n    \"--backend-store-uri\",\n    envvar=\"MLFLOW_BACKEND_STORE_URI\",\n    metavar=\"PATH\",\n    default=None,\n    help=\"URI to which to persist experiment and run data. Acceptable URIs are \"\n    \"SQLAlchemy-compatible database connection strings \"\n    \"(e.g. 'sqlite:///path/to/file.db') or local filesystem URIs \"\n    \"(e.g. 'file:///absolute/path/to/directory'). By default, data is logged to a local \"\n    \"SQLite database (sqlite:///mlflow.db), falling back to the ./mlruns directory when an \"\n    \"existing ./mlruns store is present.\",","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/cli/__init__.py#L345-L381","documentation":"Raised as click UsageError by _validate_static_prefix when the --static-prefix value ends with '/'. MLflow normalizes prefix joining internally, so a trailing slash would produce double-slash URLs; the CLI rejects it to keep path composition deterministic. The message mirrors the check directly.","triggerScenarios":"Running `mlflow server --static-prefix /mlflow/` (trailing slash).","commonSituations":"Copy-pasting a URL path with a trailing slash from browser or proxy config; shell autocomplete or heredoc accidentally appending '/'.","solutions":["Strip the trailing slash, e.g. --static-prefix /mlflow","Sanitize the value in deployment scripts (e.g. `PREFIX=${PREFIX%/}`) before invoking the CLI"],"exampleFix":"# before\nmlflow server --static-prefix /mlflow/\n\n# after\nmlflow server --static-prefix /mlflow","handlingStrategy":"validation","validationCode":"prefix = raw_prefix.rstrip(\"/\") or \"/\"","typeGuard":null,"tryCatchPattern":"try:\n    validate_fn(ctx, param, value)\nexcept click.UsageError as e:\n    if \"end with a '/'\" in str(e):\n        value = value.rstrip(\"/\")\n        validate_fn(ctx, param, value)\n    else:\n        raise","preventionTips":["Strip trailing slashes when reading prefixes from URLs or proxy configs","Centralize prefix construction in one function used by all scripts","Add shell expansion like PREFIX=${PREFIX%/} in CI variables"],"tags":["cli","server","validation","url-path"],"backgroundTag":"invalid-argument","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}