Skip to content

fix: isolate langfuse env vars#2022

Merged
lizradway merged 1 commit intostrands-agents:mainfrom
lizradway:isolate-langfuse
Mar 31, 2026
Merged

fix: isolate langfuse env vars#2022
lizradway merged 1 commit intostrands-agents:mainfrom
lizradway:isolate-langfuse

Conversation

@lizradway
Copy link
Copy Markdown
Member

Description

Fix tracer tests failing when developers have Langfuse environment variables set locally introduced in #1768

The is_langfuse property checks three env vars (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, LANGFUSE_BASE_URL), but the moto_env test fixture only cleared the first one. When a developer has Langfuse configured locally, the remaining env vars leak into tests, causing is_langfuse to unexpectedly return True. This triggers extra span.set_attributes() calls that break assert_called_once_with assertions.

The fix adds monkeypatch.delenv calls for OTEL_EXPORTER_OTLP_TRACES_ENDPOINT and LANGFUSE_BASE_URL to the moto_env fixture, ensuring all three langfuse-related env vars are cleared for tests.

Related Issues

N/A

Documentation PR

N/A

Type of Change

Bug fix

Testing

How have you tested the change?

  • I ran hatch run prepare
  • Verified all 76 tracer tests pass with Langfuse env vars set locally

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@lizradway lizradway marked this pull request as ready for review March 31, 2026 20:51
@lizradway lizradway temporarily deployed to manual-approval March 31, 2026 20:51 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown

Assessment: Approve

Clean, focused bug fix that correctly clears all three environment variables checked by the is_langfuse property, ensuring developer local configurations don't leak into tests.

Review Summary
  • Completeness: The fix covers all env vars checked by is_langfuse (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, LANGFUSE_BASE_URL)
  • Documentation: Not required for this test infrastructure fix

Nice minimal fix! 👍

@lizradway lizradway merged commit 5391794 into strands-agents:main Mar 31, 2026
30 of 36 checks passed
@lizradway lizradway deleted the isolate-langfuse branch March 31, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants