Empty environment variables are treated as set
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
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. Withsend_to_logfire(SendToLogfire::IfTokenPresent)the SDK sends data with an empty bearer token instead of staying local; with the default it skips theTokenRequirederror and fails at export time.LOGFIRE_SEND_TO_LOGFIRE=""makesconfigure()fail withinvalid 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=""setsservice.nameto an empty string instead of falling back toOTEL_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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pydantic/logfire-rust
-
Upgrade OpenTelemetry to preserve HTTP export errorsPossibly taken @bruno-espino claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
pydantic/logfire-rust#161 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
pydantic/logfire-rust#149 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
pydantic/logfire-rust#141 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
pydantic/logfire-rust#105 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
pydantic/logfire-rust#53 · 1 comment ·
All issues in pydantic/logfire-rust
Similar issues
-
bug UI
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
wardian-app/Wardian#1746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jlcodes99/cockpit-tools#3125 ·
Maintainers usually reply within 2 days
-
bug user-sprint
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Vondor/KassenSturz#967 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
area:build bug effort:low P5 source:agent
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day