Empty environment variables are treated as set

Open
#159 1 comment 0 reactions 0 assignees View on GitHub

@RaphaelFakhri is already working on this.

Since Nov 3, 2026.

  • #160 by @RaphaelFakhri — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
backend

Research direction

Start with logfire/src/internal/env.rs and inspect get_optional_env, then check how configure() reads the LOGFIRE_* and OTEL_* values. The expected behavior is that empty strings act like unset variables; verify the affected configuration cases, including token handling and fallback to OTEL_SERVICE_NAME.

Written by the indexing model from the issue text.

Description

logfire::configure() reads LOGFIRE_* and OTEL_* environment variables through get_optional_env (logfire/src/internal/env.rs), which returns Some("") for a variable that is set to an empty string. The OpenTelemetry specification requires SDKs to interpret an empty value the same as an unset variable, and the Logfire Python SDK does so (if value: in config_params.py).

Empty variables are common in container setups, for example LOGFIRE_TOKEN=${LOGFIRE_TOKEN} in a Compose file when the host variable is not defined.

Effects

  • LOGFIRE_TOKEN="" counts as a token. With send_to_logfire(SendToLogfire::IfTokenPresent) the SDK sends data with an empty bearer token instead of staying local; with the default it skips the TokenRequired error and fails at export time.
  • LOGFIRE_SEND_TO_LOGFIRE="" makes configure() fail with invalid configuration value for LOGFIRE_SEND_TO_LOGFIRE: '' instead of using the default.
  • LOGFIRE_BASE_URL="" replaces the region URL from the token with an empty base URL.
  • LOGFIRE_SERVICE_NAME="" sets service.name to an empty string instead of falling back to OTEL_SERVICE_NAME.

Reproduction

// LOGFIRE_TOKEN= cargo run
let logfire = logfire::configure()
    .send_to_logfire(logfire::config::SendToLogfire::IfTokenPresent)
    .finish()?;
// Data is exported to https://logfire-us.pydantic.dev with `Authorization: Bearer `.

Expected behavior

An empty environment variable behaves exactly like an unset one.

Dominant language
Rust
Stars
78
Forks
13
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pydantic/logfire-rust

All issues in pydantic/logfire-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.