{"record":{"id":"f71584616dabb2b5","repo":"mlflow/mlflow","slug":"str-e-f71584","errorCode":null,"errorMessage":"{str(e)}","messagePattern":"\\{str\\(e\\)\\}","errorType":"exception","errorClass":"MlflowTraceArchivalMalformedTrace","httpStatus":null,"severity":"error","filePath":"mlflow/store/artifact/artifact_repo.py","lineNumber":603,"sourceCode":"\n    def upload_archived_trace_data(self, trace_data: TraceData) -> None:\n        \"\"\"\n        Upload archived trace data as OTLP protobuf to ``traces.pb``.\n\n        Args:\n            trace_data: The archived trace data as a ``TraceData`` object.\n        \"\"\"\n        from mlflow.exceptions import MlflowTraceArchivalMalformedTrace\n        from mlflow.tracing.otel.otel_archival import spans_to_traces_data_pb\n\n        if not isinstance(trace_data, TraceData):\n            raise MlflowException.invalid_parameter_value(\n                \"Archived trace data must be a TraceData object.\"\n            )\n        try:\n            data = spans_to_traces_data_pb(trace_data.spans)\n        except (MlflowException, TypeError, ValueError) as e:\n            raise MlflowTraceArchivalMalformedTrace(str(e)) from e\n        self.upload_archived_trace_data_bytes(data)\n\n    def upload_archived_trace_data_bytes(self, data: bytes) -> None:\n        \"\"\"\n        Upload serialized archived trace data bytes to ``traces.pb``.\n\n        Backends can override this hook to avoid the default temp-file staging path when their\n        storage SDK supports in-memory uploads or more efficient multipart transfer primitives.\n        Overriding is useful for remote object stores where direct byte uploads can reduce local\n        disk I/O and let the backend apply transport-specific optimizations.\n        \"\"\"\n        with _write_local_temp_trace_data_pb_file(data) as temp_file:\n            self.log_artifact(temp_file)\n\n    def upload_attachment(self, attachment_id: str, content_bytes: bytes) -> None:\n        _validate_attachment_path(attachment_id)\n        with tempfile.TemporaryDirectory() as temp_dir:\n            temp_file = Path(temp_dir, attachment_id)","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/artifact/artifact_repo.py#L585-L621","documentation":"Raised as MlflowTraceArchivalMalformedTrace by ArtifactRepo.upload_archived_trace_data when spans_to_traces_data_pb(trace_data.spans) fails while converting the TraceData spans to OTLP protobuf. The original error message is preserved in the new message; it indicates the archived trace payload is structurally invalid and cannot be serialized.","triggerScenarios":"Calling upload_archived_trace_data with a TraceData whose .spans contain malformed/None span fields (missing trace_id/span_id, invalid timestamps or attribute types) such that spans_to_traces_data_pb raises MlflowException, TypeError, or ValueError.","commonSituations":"Traces ingested from external systems with non-OTLP-compatible attribute values; partially constructed Span entities missing required identifiers; version mismatches between the SDK that produced the spans and the current MLflow protobuf schema.","solutions":["Read the wrapped message to find the offending span/field and fix the Span construction (valid trace_id, span_id, timestamps, attribute values).","Sanitize span attributes before conversion — drop or coerce values that are not OTLP-compatible primitives (str, bool, int, float, bytes).","Validate spans by round-tripping through spans_to_traces_data_pb locally before upload and skip/log malformed spans.","Catch MlflowTraceArchivalMalformedTrace at the call site and decide whether to skip archival for that trace."],"exampleFix":"// before\nrepo.upload_archived_trace_data(TraceData(spans=raw_spans))\n\n// after\nfrom mlflow.exceptions import MlflowTraceArchivalMalformedTrace\ntry:\n    repo.upload_archived_trace_data(TraceData(spans=raw_spans))\nexcept MlflowTraceArchivalMalformedTrace as e:\n    logger.warning(\"Skipping malformed trace: %s\", e)","handlingStrategy":"validation","validationCode":"def spans_look_valid(trace_data):\n    for s in trace_data.spans:\n        if not s.trace_id or not s.span_id or s.start_time is None or s.end_time is None:\n            return False\n        for v in (s.attributes or {}).values():\n            if not isinstance(v, (str, bool, int, float, bytes)):\n                return False\n    return True","typeGuard":null,"tryCatchPattern":"from mlflow.exceptions import MlflowTraceArchivalMalformedTrace\ntry:\n    repo.upload_archived_trace_data(trace_data)\nexcept MlflowTraceArchivalMalformedTrace as e:\n    logger.warning(\"Skipping malformed archived trace: %s\", e)","preventionTips":["Sanitize span attributes to OTLP-compatible primitive types before archival.","Ensure every Span has non-empty trace_id/span_id and valid start/end timestamps.","Keep MLflow versions consistent between span-producing and archiving components.","Test archival round-trip (upload + download_archived_trace_data) in CI."],"tags":["mlflow","tracing","protobuf","malformed-data"],"backgroundTag":"malformed-payload","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}