Could not add LangFuse (regression of PR #7571) #5225

Closed
opened 2026-02-21 18:09:57 -05:00 by yindo · 5 comments
Owner

Originally created by @CXwudi on GitHub (Aug 26, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.7.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Create a random App,
  2. Go to the Monitoring tab
  3. Setup Langfuse

✔️ Expected Behavior

Langfuse config should work given the valid secret/public key pairs and the domain.

Actual Behavior

image

Originally created by @CXwudi on GitHub (Aug 26, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.7.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Create a random App, 2. Go to the Monitoring tab 3. Setup Langfuse ### ✔️ Expected Behavior Langfuse config should work given the valid secret/public key pairs and the domain. ### ❌ Actual Behavior ![image](https://github.com/user-attachments/assets/6cdd281a-98b4-472a-b1d6-f995a3589f82)
yindo added the 🐞 bug label 2026-02-21 18:09:57 -05:00
yindo closed this issue 2026-02-21 18:09:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 26, 2024):

I found a similar unsolved discussion regarding a URL error when adding Langfuse [1].

To resolve the configuration error for LangfuseConfig in a self-hosted Dify 0.7.2 setup, where the error message indicates a missing project_key field, follow these steps:

  1. Create a project in Langfuse:

    • Register and log in to Langfuse on the official website.
    • Create a new project by clicking New on the homepage and note down the project details.
  2. Create project API credentials:

    • In the project settings, click Settings in the left sidebar.
    • Click Create API Keys to generate API credentials.
    • Copy and save the Secret Key, Public Key, and Host.
  3. Configure Langfuse in Dify:

    • Open the application you need to monitor in Dify.
    • Navigate to Monitoring in the side menu and select Tracing app performance.
    • Paste the Secret Key, Public Key, and Host into the configuration fields.
  4. Retrieve and set the project_key:

    • If the project_key is not automatically retrieved, you can manually set it in the configuration file. Here is an example of how the configuration might look:
langfuse:
  secret_key: "your_secret_key"
  public_key: "your_public_key"
  host: "your_host"
  project_key: "your_project_key"

Ensure that all the required fields, including project_key, are correctly set in your configuration file. This should resolve the missing project_key field error.

Additionally, if you are using the OpsService class in Dify, it automatically handles the retrieval and setting of the project_key if it is missing. The get_tracing_app_config method in OpsService checks if the project_key is present and retrieves it if necessary:

if tracing_provider == 'langfuse' and ('project_key' not in decrypt_tracing_config or not decrypt_tracing_config.get('project_key')):
    project_key = OpsTraceManager.get_trace_config_project_key(decrypt_tracing_config, tracing_provider)
    decrypt_tracing_config['project_key'] = project_key

Make sure your configuration and setup align with these methods to ensure the project_key is correctly managed [2][3][4][5].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 26, 2024): <!-- Answer --> I found a similar unsolved discussion regarding a URL error when adding Langfuse <sup>[[1]](https://github.com/langgenius/dify/discussions/5947)</sup>. To resolve the configuration error for `LangfuseConfig` in a self-hosted Dify 0.7.2 setup, where the error message indicates a missing `project_key` field, follow these steps: 1. **Create a project in Langfuse**: - Register and log in to Langfuse on the [official website](https://langfuse.com/). - Create a new project by clicking **New** on the homepage and note down the project details. 2. **Create project API credentials**: - In the project settings, click **Settings** in the left sidebar. - Click **Create API Keys** to generate API credentials. - Copy and save the `Secret Key`, `Public Key`, and `Host`. 3. **Configure Langfuse in Dify**: - Open the application you need to monitor in Dify. - Navigate to **Monitoring** in the side menu and select **Tracing app performance**. - Paste the `Secret Key`, `Public Key`, and `Host` into the configuration fields. 4. **Retrieve and set the `project_key`**: - If the `project_key` is not automatically retrieved, you can manually set it in the configuration file. Here is an example of how the configuration might look: ```yaml langfuse: secret_key: "your_secret_key" public_key: "your_public_key" host: "your_host" project_key: "your_project_key" ``` Ensure that all the required fields, including `project_key`, are correctly set in your configuration file. This should resolve the missing `project_key` field error. Additionally, if you are using the `OpsService` class in Dify, it automatically handles the retrieval and setting of the `project_key` if it is missing. The `get_tracing_app_config` method in `OpsService` checks if the `project_key` is present and retrieves it if necessary: ```python if tracing_provider == 'langfuse' and ('project_key' not in decrypt_tracing_config or not decrypt_tracing_config.get('project_key')): project_key = OpsTraceManager.get_trace_config_project_key(decrypt_tracing_config, tracing_provider) decrypt_tracing_config['project_key'] = project_key ``` Make sure your configuration and setup align with these methods to ensure the `project_key` is correctly managed <sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/guides/monitoring/integrate-external-ops-tools/integrate-langfuse.md)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/ops/langfuse_trace/langfuse_trace.py)</sup><sup>[[4]](https://github.com/langgenius/dify/blob/main/api/services/ops_service.py)</sup><sup>[[5]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/monitoring/integrate-external-ops-tools/integrate-langfuse.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@CXwudi commented on GitHub (Aug 26, 2024):

PR https://github.com/langgenius/dify/pull/7571/ added a new field called project_key. However, it looks like the pydantic check happens before https://github.com/langgenius/dify/blob/b7ff98d7ff8bd14ed795fa35d528b55ba94589f8/api/services/ops_service.py#L67 is get called. Hence, it is complaining missing the required field.

My suggestion fix is to keep LangfuseConfig as it, and create a new DTO object called maybe LangFuseNewConfigDto that only has public_key, secret_key, and host. This DTO is only used when setting up a new langfuse config.

@CXwudi commented on GitHub (Aug 26, 2024): PR https://github.com/langgenius/dify/pull/7571/ added a new field called `project_key`. However, it looks like the pydantic check happens before https://github.com/langgenius/dify/blob/b7ff98d7ff8bd14ed795fa35d528b55ba94589f8/api/services/ops_service.py#L67 is get called. Hence, it is complaining missing the required field. My suggestion fix is to keep [`LangfuseConfig`](https://github.com/langgenius/dify/blob/b7ff98d7ff8bd14ed795fa35d528b55ba94589f8/api/core/ops/entities/config_entity.py#L18) as it, and create a new DTO object called maybe `LangFuseNewConfigDto` that only has `public_key`, `secret_key`, and `host`. This DTO is only used when setting up a new langfuse config.
Author
Owner

@huangying-just commented on GitHub (Aug 27, 2024):

same question occurred. need to be fixed.

@huangying-just commented on GitHub (Aug 27, 2024): same question occurred. need to be fixed.
Author
Owner

@gaoyue1989 commented on GitHub (Sep 1, 2024):

I think this occurred when the front-end API call was made and the "project_key" field was not passed. When I manually invoked the API, it returned success.

@gaoyue1989 commented on GitHub (Sep 1, 2024): I think this occurred when the front-end API call was made and the "project_key" field was not passed. When I manually invoked the API, it returned success.
Author
Owner

@CXwudi commented on GitHub (Sep 1, 2024):

@gaoyue1989 I figured that as well. But I am not sure if the project_key should be needed when setting up a brand new LangFuse tracing

@CXwudi commented on GitHub (Sep 1, 2024): @gaoyue1989 I figured that as well. But I am not sure if the `project_key` should be needed when setting up a brand new LangFuse tracing
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5225