Skip to content

Fix number env vars not coercing string -> number for LANGFUSE_INIT_PROJECT_RETENTION, more #8103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025

Conversation

jdidzik
Copy link
Contributor

@jdidzik jdidzik commented Jul 24, 2025

What does this PR do?

This PR fixes config of the LANGFUSE_INIT_PROJECT_RETENTION and LANGFUSE_MAX_HISTORIC_EVAL_CREATION_LIMIT via env.
coerce was missing on both env vars. It seems all other number() envs use this, so it was probably an oversight that it was not added.

When setting up retention in our chart, Langfuse fails to validate the env var LANGFUSE_INIT_PROJECT_RETENTION when configured in additionalEnv as follows:

additionalEnv:
  - name: LANGFUSE_INIT_PROJECT_RETENTION
    value: "14"

Langfuse logs these errors when attempting to start:

Error: An error occurred while loading instrumentation hook: Invalid environment variables
LANGFUSE_INIT_PROJECT_RETENTION: [ 'Expected number, received string' ]

Note that setting the value unquoted results in a parsing error in helm:

✗ Helm upgrade failed for release langfuse/langfuse with chart langfuse@1.3.1: failed to create resource: Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal number into Go struct field EnvVar.spec.template.spec.containers.env.value of type string

While in here, I found that LANGFUSE_MAX_HISTORIC_EVAL_CREATION_LIMIT will suffer from the same issue, so I've also fixed that.

Type of change

  • Bug fix

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Important

Fixes environment variable coercion for LANGFUSE_INIT_PROJECT_RETENTION and LANGFUSE_MAX_HISTORIC_EVAL_CREATION_LIMIT in web/src/env.mjs.

  • Bug Fix:
    • Add z.coerce to LANGFUSE_INIT_PROJECT_RETENTION and LANGFUSE_MAX_HISTORIC_EVAL_CREATION_LIMIT in web/src/env.mjs to coerce strings to numbers.
    • Fixes validation error: "Expected number, received string" for LANGFUSE_INIT_PROJECT_RETENTION when set via Helm with quotes.
    • Prevents parsing error in Helm when setting LANGFUSE_INIT_PROJECT_RETENTION without quotes.

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

@CLAassistant
Copy link

CLAassistant commented Jul 24, 2025

CLA assistant check
All committers have signed the CLA.

@jdidzik jdidzik changed the title Fix number env vars not coercing string -> number in Fix number env vars not coercing string -> number for LANGFUSE_INIT_PROJECT_RETENTION, more Jul 24, 2025
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jul 24, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 31, 2025
@Steffen911 Steffen911 merged commit ea338ed into langfuse:main Jul 31, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants