You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds v4 deprecation notices across all package READMEs, ships two bug fixes (environment-validation false-positive suppression and a TypeError crash guard in the LangChain callback), and bumps all packages to 3.38.6.
Deprecation notices: Each package's README now has a prominent [!IMPORTANT] banner directing users to the v4 TypeScript SDK docs, replacing the older v2 migration note in the root README.
Environment validation fix (langfuse-core/src/index.ts): The invalid-environment error is now suppressed when _isLocalEventExportEnabled is true, preventing false-positive warnings during local testing with arbitrary environment names.
LangChain null-safety fix (langfuse-langchain/src/callback.ts): Adds ?? {} so llmUsage is never undefined; previously, if both extractUsageMetadata and output.llmOutput?.[\"tokenUsage\"] were nullish, the subsequent \"promptTokens\" in llmUsage expression would throw a TypeError at runtime.
Version bumps: All packages advance from 3.38.4 → 3.38.6; the apparent skip of 3.38.5 is expected — the git history shows v3.38.5 was tagged as an intermediate release within this PR's commit range before two additional fixes brought it to 3.38.6.
Confidence Score: 5/5
Safe to merge — all code changes are targeted bug fixes with no regressions introduced
Both code changes are correct: the ?? {} fallback prevents a real runtime crash path, and the !_isLocalEventExportEnabled guard correctly uses the raw constructor param (before this.isLocalEventExportEnabled is assigned). Version skipping is explained by the git history. No P0/P1 findings.
No files require special attention
Important Files Changed
Filename
Overview
README.md
Adds v4 deprecation notice and removes the now-stale v2 migration notice
langfuse-core/src/index.ts
Suppresses spurious environment-pattern validation error when local event export is enabled; uses the raw constructor param (not this.isLocalEventExportEnabled) which is correct at this point in the constructor
langfuse-langchain/src/callback.ts
Adds ?? {} fallback for llmUsage to prevent a runtime TypeError from the in operator when both usage sources are undefined
langfuse-core/package.json
Version bumped to 3.38.6 (reflecting two incremental releases that landed within this PR's commit range)
langfuse-langchain/package.json
Version and peer dependency ranges bumped to 3.38.6 consistently
lerna.json
Monorepo version set to 3.38.6 to match all package versions
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[LangfuseCoreStateless constructor] --> B{environment set?}
B -- No --> E[skip validation]
B -- Yes --> C{matches ENVIRONMENT_PATTERN or whitelisted?}
C -- Yes --> E
C -- No --> D{_isLocalEventExportEnabled?}
D -- Yes --> E[skip validation - new: suppress false-positive]
D -- No --> F[emit error: Invalid tracing environment]
G[handleLLMEnd] --> H[extractUsageMetadata]
H -- UsageMetadata --> I[llmUsage = UsageMetadata]
H -- undefined --> J{output.llmOutput tokenUsage?}
J -- value --> I
J -- undefined --> K[llmUsage = empty object - new: prevents TypeError]
I --> L[build usageDetails via in operator]
K --> L
The added && !_isLocalEventExportEnabled check suppresses invalid-environment diagnostics based on the raw constructor flag, not the finalized mode. In LangfuseCoreStateless the instance can later disable local export when _projectId is missing, which means the SDK falls back to server ingestion while still skipping this validation warning; with an invalid environment, events can be rejected server-side without the expected error message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: Experimental PR review
Greptile Summary
This PR adds v4 deprecation notices across all package READMEs, ships two bug fixes (environment-validation false-positive suppression and a
TypeErrorcrash guard in the LangChain callback), and bumps all packages to3.38.6.[!IMPORTANT]banner directing users to the v4 TypeScript SDK docs, replacing the older v2 migration note in the root README.langfuse-core/src/index.ts): The invalid-environment error is now suppressed when_isLocalEventExportEnabledistrue, preventing false-positive warnings during local testing with arbitrary environment names.langfuse-langchain/src/callback.ts): Adds?? {}sollmUsageis neverundefined; previously, if bothextractUsageMetadataandoutput.llmOutput?.[\"tokenUsage\"]were nullish, the subsequent\"promptTokens\" in llmUsageexpression would throw aTypeErrorat runtime.3.38.4→3.38.6; the apparent skip of3.38.5is expected — the git history showsv3.38.5was tagged as an intermediate release within this PR's commit range before two additional fixes brought it to3.38.6.Confidence Score: 5/5
Safe to merge — all code changes are targeted bug fixes with no regressions introduced
Both code changes are correct: the
?? {}fallback prevents a real runtime crash path, and the!_isLocalEventExportEnabledguard correctly uses the raw constructor param (beforethis.isLocalEventExportEnabledis assigned). Version skipping is explained by the git history. No P0/P1 findings.No files require special attention
Important Files Changed
this.isLocalEventExportEnabled) which is correct at this point in the constructor?? {}fallback forllmUsageto prevent a runtime TypeError from theinoperator when both usage sources are undefinedFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[LangfuseCoreStateless constructor] --> B{environment set?} B -- No --> E[skip validation] B -- Yes --> C{matches ENVIRONMENT_PATTERN or whitelisted?} C -- Yes --> E C -- No --> D{_isLocalEventExportEnabled?} D -- Yes --> E[skip validation - new: suppress false-positive] D -- No --> F[emit error: Invalid tracing environment] G[handleLLMEnd] --> H[extractUsageMetadata] H -- UsageMetadata --> I[llmUsage = UsageMetadata] H -- undefined --> J{output.llmOutput tokenUsage?} J -- value --> I J -- undefined --> K[llmUsage = empty object - new: prevents TypeError] I --> L[build usageDetails via in operator] K --> LReviews (1): Last reviewed commit: "fix(langchain): handle null tokenUsage" | Re-trigger Greptile