Skip to content

Conversation

@nimarb
Copy link
Contributor

@nimarb nimarb commented Sep 18, 2025

Important

Add test to ensure multiple update_current_trace calls retain attributes and refactor existing tests for clarity in test_core_sdk.py.

  • Tests:
    • Add test_create_update_current_trace to verify multiple update_current_trace calls retain all attributes.
    • Refactor assertions in test_core_sdk.py for clarity and consistency, particularly in test_create_update_trace and test_that_generation_like_properties_are_actually_created.
    • Minor formatting changes in test_start_as_current_observation_types and test_that_generation_like_properties_are_actually_created.

This description was created by Ellipsis for fcf644e. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Summary

Updated On: 2025-09-18 12:12:40 UTC

This PR adds a new test function test_create_update_current_trace to validate that multiple calls to update_current_trace properly preserve previously set attributes instead of overwriting them. The test creates a trace using langfuse.start_as_current_span() context manager, then calls update_current_trace twice with different sets of attributes to ensure proper merging behavior.

The test flow:

  1. Creates a span context and uses update_current_trace to set initial properties (name, user_id, metadata, public flag, input)
  2. Makes a second call to update_current_trace with additional metadata, version, and updated public flag
  3. Verifies that all attributes from both calls are preserved in the final trace object

This addresses a potential bug (referenced as LFE-6798 in the branch name) where subsequent updates were dropping previously set trace attributes. The test integrates with the existing test suite's pattern of using the Langfuse SDK and API validation through get_api().trace.get() calls.

The PR also includes minor code formatting improvements, breaking long assertion statements across multiple lines to improve readability and comply with line length standards.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only adds test coverage without modifying production code
  • Score reflects the addition of valuable test coverage for a specific edge case with no changes to core functionality
  • No files require special attention as this is purely additive test code following established patterns

@nimarb nimarb marked this pull request as ready for review September 18, 2025 12:11
@nimarb nimarb enabled auto-merge (squash) September 18, 2025 12:11
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@nimarb nimarb merged commit 33d9086 into main Sep 18, 2025
11 checks passed
@nimarb nimarb deleted the nimar/lfe-6798-update-current-trace-test branch September 18, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants