From 04c56efc7b8b15212b33054708029e0f17235b0d Mon Sep 17 00:00:00 2001 From: Sakshar Thakkar Date: Fri, 30 Jan 2026 16:45:52 -0800 Subject: [PATCH 1/2] fix: use fixed source=4 (Robots) for UiPathSpan instead of reading from attributes Co-Authored-By: Claude Opus 4.5 --- pyproject.toml | 2 +- src/uipath/tracing/_utils.py | 4 +--- uv.lock | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ff52e089a..f4393c0c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath" -version = "2.6.22" +version = "2.6.23" description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools." readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/src/uipath/tracing/_utils.py b/src/uipath/tracing/_utils.py index 3df356d05..e28375943 100644 --- a/src/uipath/tracing/_utils.py +++ b/src/uipath/tracing/_utils.py @@ -43,7 +43,7 @@ class UiPathSpan: folder_key: Optional[str] = field( default_factory=lambda: env.get("UIPATH_FOLDER_KEY", "") ) - source: Optional[int] = None + source: int = 4 # SourceEnum.Robots for Python SDK span_type: str = "Coded Agents" process_key: Optional[str] = field( default_factory=lambda: env.get("UIPATH_PROCESS_UUID") @@ -248,7 +248,6 @@ def otel_span_to_uipath_span( execution_type = attributes_dict.get("executionType") agent_version = attributes_dict.get("agentVersion") reference_id = attributes_dict.get("referenceId") - source = attributes_dict.get("source") # Create UiPathSpan from OpenTelemetry span start_time = datetime.fromtimestamp( @@ -278,7 +277,6 @@ def otel_span_to_uipath_span( execution_type=execution_type, agent_version=agent_version, reference_id=reference_id, - source=source, ) @staticmethod diff --git a/uv.lock b/uv.lock index b3289b67b..88710ccf2 100644 --- a/uv.lock +++ b/uv.lock @@ -2491,7 +2491,7 @@ wheels = [ [[package]] name = "uipath" -version = "2.6.22" +version = "2.6.23" source = { editable = "." } dependencies = [ { name = "applicationinsights" }, From 44ac507522c8ad74c9d7f21ba49a3f9f36d69355 Mon Sep 17 00:00:00 2001 From: Sakshar Thakkar Date: Fri, 30 Jan 2026 16:54:30 -0800 Subject: [PATCH 2/2] test: add unit test for source field defaulting to 4 (Robots) Co-Authored-By: Claude Opus 4.5 --- tests/tracing/test_span_utils.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/tracing/test_span_utils.py b/tests/tracing/test_span_utils.py index 0da577bca..e0e24275f 100644 --- a/tests/tracing/test_span_utils.py +++ b/tests/tracing/test_span_utils.py @@ -320,3 +320,36 @@ def test_uipath_span_missing_execution_type_and_agent_version(self): assert span_dict["ExecutionType"] is None assert span_dict["AgentVersion"] is None + + @patch.dict(os.environ, {"UIPATH_ORGANIZATION_ID": "test-org"}) + def test_uipath_span_source_defaults_to_robots(self): + """Test that Source defaults to 4 (Robots) and ignores attributes.source.""" + mock_span = Mock(spec=OTelSpan) + + trace_id = 0x123456789ABCDEF0123456789ABCDEF0 + span_id = 0x0123456789ABCDEF + mock_context = SpanContext(trace_id=trace_id, span_id=span_id, is_remote=False) + mock_span.get_span_context.return_value = mock_context + + mock_span.name = "test-span" + mock_span.parent = None + mock_span.status.status_code = StatusCode.OK + # source in attributes should NOT override top-level Source + mock_span.attributes = {"source": "runtime"} + mock_span.events = [] + mock_span.links = [] + + current_time_ns = int(datetime.now().timestamp() * 1e9) + mock_span.start_time = current_time_ns + mock_span.end_time = current_time_ns + 1000000 + + uipath_span = _SpanUtils.otel_span_to_uipath_span(mock_span) + span_dict = uipath_span.to_dict() + + # Top-level Source should be 4 (Robots), not from attributes + assert uipath_span.source == 4 + assert span_dict["Source"] == 4 + + # attributes.source string should still be in Attributes JSON + attrs = json.loads(span_dict["Attributes"]) + assert attrs["source"] == "runtime"