{"record":{"id":"52feb464d4254b56","repo":"mlflow/mlflow","slug":"invalid-parameter-value-52feb4","errorCode":"INVALID_PARAMETER_VALUE","errorMessage":"run_id cannot be empty","messagePattern":"run_id cannot be empty","errorType":"exception","errorClass":"MlflowException","httpStatus":400,"severity":"error","filePath":"mlflow/tracking/_tracking_service/client.py","lineNumber":1109,"sourceCode":"        \"\"\"\n        return self.store.remove_dataset_from_experiments(dataset_id, experiment_ids)\n\n    def link_traces_to_run(self, trace_ids: list[str], run_id: str) -> None:\n        \"\"\"\n        Link multiple traces to a run by creating entity associations.\n\n        Args:\n            trace_ids: List of trace IDs to link to the run. Maximum 100 traces allowed.\n            run_id: ID of the run to link traces to.\n\n        Raises:\n            MlflowException: If more than 100 traces are provided or run_id is empty.\n        \"\"\"\n        if not trace_ids:\n            return\n\n        if not run_id:\n            raise MlflowException.invalid_parameter_value(\"run_id cannot be empty\")\n\n        if len(trace_ids) > 100:\n            raise MlflowException.invalid_parameter_value(\n                f\"Cannot link more than 100 traces to a run in a single request. \"\n                f\"Provided {len(trace_ids)} traces.\"\n            )\n\n        return self.store.link_traces_to_run(trace_ids, run_id)\n\n    def unlink_traces_from_run(self, trace_ids: list[str], run_id: str) -> None:\n        \"\"\"\n        Unlink multiple traces from a run by removing entity associations.\n\n        Args:\n            trace_ids: List of trace IDs to unlink from the run.\n            run_id: ID of the run to unlink traces from.\n\n        Raises:","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/tracking/_tracking_service/client.py#L1091-L1127","documentation":"Raised by MlflowClient.link_traces_to_run when the run_id argument is empty/None. Linking traces to a run requires a valid run ID, and the client rejects an empty one before sending a request to the tracking store.","triggerScenarios":"Calling client.link_traces_to_run(trace_ids, run_id) with run_id='' or None, typically because a variable was never populated, mlflow.active_run() returned None, or the run ID was read from an unset environment variable (e.g. MLFLOW_RUN_ID).","commonSituations":"Notebook scripts run outside mlflow.start_run() so there is no active run; CI pipelines missing run-id environment variables; deserialized configs where the run_id key is empty.","solutions":["Pass a valid run_id string obtained from mlflow.active_run().info.run_id or the MLflow UI.","Start a run first (with mlflow.start_run()) if you expect the run to exist.","Guard the call: return early or raise a clear error if not run_id."],"exampleFix":"// before\nclient.link_traces_to_run(trace_ids, run_id)  # run_id is None\n\n// after\nrun = mlflow.active_run()\nif run:\n    client.link_traces_to_run(trace_ids, run.info.run_id)","handlingStrategy":"validation","validationCode":"if not run_id:\n    raise ValueError(\"link_traces_to_run requires a non-empty run_id\")\nclient.link_traces_to_run(trace_ids, run_id)","typeGuard":"def has_run_id(run_id) -> bool:\n    return isinstance(run_id, str) and run_id.strip() != \"\"","tryCatchPattern":"try:\n    client.link_traces_to_run(trace_ids, run_id)\nexcept MlflowException as e:\n    if e.error_code == \"INVALID_PARAMETER_VALUE\" and \"run_id cannot be empty\" in str(e):\n        logger.error(\"No run_id available; ensure mlflow.start_run() or set run_id explicitly\")\n    else:\n        raise","preventionTips":["Resolve run_id from mlflow.active_run().info.run_id inside a start_run context.","Validate run_id is a non-empty string before any tracking-store call.","Never rely on unset MLFLOW_RUN_ID env vars without a fallback check."],"tags":["mlflow","tracking","traces","validation","empty-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}