{"record":{"id":"6ac9203d10b6a5ed","repo":"mlflow/mlflow","slug":"invalid-parameter-value-6ac920","errorCode":"INVALID_PARAMETER_VALUE","errorMessage":"The specified input argument index ({input_arg_index}) is out of range for the function signature: {input_arg_index},{arg_names}","messagePattern":"The specified input argument index \\((.+?)\\) is out of range for the function signature: (.+?),(.+?)","errorType":"validation","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/models/signature.py","lineNumber":335,"sourceCode":"    \"\"\"\n    Extract type hints from a function.\n\n    Args:\n        f: Function to extract type hints from.\n        input_arg_index: Index of the function argument that corresponds to the model input.\n\n    Returns:\n        A `_TypeHints` object containing the input and output type hints.\n    \"\"\"\n    if not hasattr(f, \"__annotations__\") and hasattr(f, \"__call__\"):\n        return _extract_type_hints(f.__call__, input_arg_index)\n\n    if f.__annotations__ == {}:\n        return _TypeHints()\n\n    arg_names = list(filter(lambda x: x != \"self\", _get_arg_names(f)))\n    if len(arg_names) - 1 < input_arg_index:\n        raise MlflowException.invalid_parameter_value(\n            f\"The specified input argument index ({input_arg_index}) is out of range for the \"\n            \"function signature: {}\".format(input_arg_index, arg_names)\n        )\n    arg_name = arg_names[input_arg_index]\n    try:\n        hints = get_type_hints(f)\n    except (\n        TypeError,\n        NameError,  # To handle this issue: https://github.com/python/typing/issues/797\n    ):\n        # ---\n        # from __future__ import annotations # postpones evaluation of 'list[str]'\n        #\n        # def f(x: list[str]) -> list[str]:\n        #          ^^^^^^^^^ Evaluating this expression ('list[str]') results in a TypeError in\n        #                    Python < 3.9 because the built-in list type is not subscriptable.\n        #     return x\n        # ---","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/models/signature.py#L317-L353","documentation":"Raised by `_extract_type_hints` in mlflow/models/signature.py when the requested `input_arg_index` points past the last argument of the function being inspected (after filtering out `self`). MLflow needs the type hint of the Nth input argument to infer a model signature, so an out-of-range index means the function has fewer signature arguments than expected.","triggerScenarios":"Calling `mlflow.models.infer_signature` / `save_model` (or `_infer_signature_from_type_hints`) on a function whose predict signature has fewer non-self arguments than the configured `input_arg_index`, e.g. `def predict(self, x)` with input_arg_index=1, or a zero-argument predict function.","commonSituations":"Wrapping a model whose predict method takes only one input while MLflow's flavor expects (context, input) or (input, params) style signatures; typos when passing `input_arg_index` through custom flavor code; refactoring a predict function to remove arguments without updating signature inference config.","solutions":["Add the missing argument(s) to the predict function signature so it has at least input_arg_index+1 non-self parameters, e.g. `def predict(self, model_input, params=None)`.","Lower the `input_arg_index` passed to signature inference so it matches an existing argument.","Verify the function is decorated/defined such that its argument names are introspectable (functools.wraps etc.) and `self` filtering matches expectations.","Print `inspect.signature(fn).parameters` to confirm the actual argument list before inferring."],"exampleFix":"// before\ndef predict(self, x):\n    ...\nmlflow.pyfunc.log_model(\"m\", python_model=model)  # input_arg_index=1\n// after\ndef predict(self, context, model_input):\n    ...\nmlflow.pyfunc.log_model(\"m\", python_model=model)","handlingStrategy":"validation","validationCode":"import inspect\nn_args = len([p for p in inspect.signature(fn).parameters if p != \"self\"])\nif n_args - 1 < input_arg_index:\n    raise ValueError(f\"{fn} has only {n_args} args; input_arg_index={input_arg_index} is out of range\")","typeGuard":"def has_input_arg_index(fn, idx: int) -> bool:\n    names = [p for p in inspect.signature(fn).parameters if p != \"self\"]\n    return 0 <= idx < len(names)","tryCatchPattern":null,"preventionTips":["Check `inspect.signature(fn).parameters` before signature inference.","Keep predict signatures in the canonical (self, input[, params]) form expected by your flavor.","Re-run signature inference tests after refactoring predict functions."],"tags":["signature","type-hints","invalid-parameter"],"backgroundTag":"invalid-parameter-value","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}