From 3d829e4ebda23c7f34e173097850945f88f58c97 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 11 Jul 2026 20:07:48 +0000 Subject: [PATCH] fix(e2e): resolve basedpyright errors in logging_client Two zero-error gate regressions from PR #32857: - completion_response_id relied on json.loads (returns Any) and dict.get on an unnarrowed dict, which triggered reportAny and reportUnknownVariableType. Route the parse through a TypeAdapter[dict[str, object]] so parsed and raw are typed and validation errors funnel through ValidationError. - LangfuseListParams(...) was constructed with the field-name kwargs trace_id and from_start_time, but pydantic's Field alias narrows the generated __init__ to traceId and fromStartTime; basedpyright flagged those calls as reportCallIssue. Pass the aliased names; populate_by_name plus by_alias serialization keep runtime identical. Co-authored-by: Krrish Dholakia --- tests/e2e/logging/logging_client.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/e2e/logging/logging_client.py b/tests/e2e/logging/logging_client.py index 06b219fc6e2..5acd12693b5 100644 --- a/tests/e2e/logging/logging_client.py +++ b/tests/e2e/logging/logging_client.py @@ -21,7 +21,7 @@ from dataclasses import dataclass from typing import Literal import pytest -from pydantic import BaseModel, ConfigDict, Field +from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, ValidationError from e2e_config import POLL_INTERVAL, POLL_TIMEOUT from e2e_gateway import Gateway, build_gateway @@ -200,15 +200,16 @@ def costs_agree(expected: float, actual: float, *, rel_tol: float = 0.05) -> boo return abs(expected - actual) <= max(1e-9, abs(expected) * rel_tol) +_JSON_OBJECT: TypeAdapter[dict[str, object]] = TypeAdapter(dict[str, object]) + + def completion_response_id(body: str) -> str | None: """SpendLogs.request_id is the chat completion body id, not x-litellm-call-id.""" if not body or body == "": return None try: - parsed = json.loads(body) - except json.JSONDecodeError: - return None - if not isinstance(parsed, dict): + parsed = _JSON_OBJECT.validate_json(body) + except ValidationError: return None raw = parsed.get("id") return raw if isinstance(raw, str) and raw else None @@ -499,9 +500,9 @@ class LoggingClient: headers=creds.auth_headers, params=LangfuseListParams( limit=100, - trace_id=trace_id, + traceId=trace_id, name=name, - from_start_time=from_start_time, + fromStartTime=from_start_time, ), response_type=LangfuseObservationList, timeout=30.0,