Bug: 500 Error in Notion Integration API #7832

Closed
opened 2026-02-21 18:22:35 -05:00 by yindo · 2 comments
Owner

Originally created by @nagaihiroki-git on GitHub (Jan 22, 2025).

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

v1.0.0-beta.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Navigate to knowledge base section
  2. Attempt to select Notion as a data source
  3. Observe 500 error in response

✔️ Expected Behavior

Image
  • When selecting Notion in knowledge base, user's Notion workspace list should be displayed
  • Pages within each workspace should be listed correctly
  • Already integrated pages should be marked as "Connected"
  • New pages should be available for selection
  • API should return a 200 status code with the list of workspaces and pages

Actual Behavior

When attempting to access Notion integration:

Backend returns 500 Internal Server Error
Frontend shows error toast notification
Console shows error in the DataSourceNotionListApi GET endpoint
Network tab shows failed API request to /notion/pre-import/pages

Image

Image

Originally created by @nagaihiroki-git on GitHub (Jan 22, 2025). ### 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 v1.0.0-beta.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Navigate to knowledge base section 2. Attempt to select Notion as a data source 3. Observe 500 error in response ### ✔️ Expected Behavior <img width="1308" alt="Image" src="https://github.com/user-attachments/assets/63c3a266-7637-4cf2-8a04-d8fce6ce9626" /> - When selecting Notion in knowledge base, user's Notion workspace list should be displayed - Pages within each workspace should be listed correctly - Already integrated pages should be marked as "Connected" - New pages should be available for selection - API should return a 200 status code with the list of workspaces and pages ### ❌ Actual Behavior When attempting to access Notion integration: Backend returns 500 Internal Server Error Frontend shows error toast notification Console shows error in the DataSourceNotionListApi GET endpoint Network tab shows failed API request to /notion/pre-import/pages ![Image](https://github.com/user-attachments/assets/ab409491-6eb2-4c5f-9880-7c937d1d4d1d) ![Image](https://github.com/user-attachments/assets/89532052-e3cd-4c36-adc2-35e5a12c1c11)
yindo added the 🐞 bug label 2026-02-21 18:22:35 -05:00
yindo closed this issue 2026-02-21 18:22:36 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 22, 2025):

Hello, @nagaihiroki-git! I'm here to assist you with any bugs, questions, or contributions. Let's work together to solve this issue.

I found a similar open issue related to a 500 Internal Server Error in the Notion integration API. The suggested solution involves checking various environment variables and configurations in your Docker setup. Here are some key points to verify:

  1. API URLs: Ensure that all relevant API URLs are correctly set and accessible.
  2. Debugging: Enable debugging to get more detailed error messages.
  3. Database and Redis Configuration: Verify that your PostgreSQL and Redis configurations are correct.
  4. Celery Configuration: Check your Celery broker URL.
  5. CORS Configuration: Ensure CORS settings are correctly configured.
  6. Storage and Sentry Configuration: Verify storage paths and Sentry DSN if used.

Additionally, the error message you encountered indicates an AttributeError related to the source_info attribute. This attribute is supposed to be defined within the DataSourceOauthBinding model, which is used to store information about the data source binding, such as details about the workspace and pages for a provider like Notion [1][2].

Make sure that the source_info attribute is correctly defined and accessible in your code. This should help resolve the 500 error you're experiencing.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot[bot] commented on GitHub (Jan 22, 2025): <!-- Greeting --> Hello, @nagaihiroki-git! I'm here to assist you with any bugs, questions, or contributions. Let's work together to solve this issue. <!-- Answer --> I found a similar open issue related to a 500 Internal Server Error in the Notion integration API. The suggested solution involves checking various environment variables and configurations in your Docker setup. Here are some key points to verify: 1. **API URLs**: Ensure that all relevant API URLs are correctly set and accessible. 2. **Debugging**: Enable debugging to get more detailed error messages. 3. **Database and Redis Configuration**: Verify that your PostgreSQL and Redis configurations are correct. 4. **Celery Configuration**: Check your Celery broker URL. 5. **CORS Configuration**: Ensure CORS settings are correctly configured. 6. **Storage and Sentry Configuration**: Verify storage paths and Sentry DSN if used. Additionally, the error message you encountered indicates an `AttributeError` related to the `source_info` attribute. This attribute is supposed to be defined within the `DataSourceOauthBinding` model, which is used to store information about the data source binding, such as details about the workspace and pages for a provider like Notion <sup>[[1]](https://github.com/langgenius/dify/issues/6479)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/controllers/console/datasets/data_source.py)</sup>. Make sure that the `source_info` attribute is correctly defined and accessible in your code. This should help resolve the 500 error you're experiencing. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/e4de54a7-bc3c-483b-a8dd-4535ee7ac0d8?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/e4de54a7-bc3c-483b-a8dd-4535ee7ac0d8?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/e4de54a7-bc3c-483b-a8dd-4535ee7ac0d8?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/e4de54a7-bc3c-483b-a8dd-4535ee7ac0d8?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e4de54a7-bc3c-483b-a8dd-4535ee7ac0d8?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/e4de54a7-bc3c-483b-a8dd-4535ee7ac0d8?feedback_type=other)</sup>
Author
Owner

@nagaihiroki-git commented on GitHub (Jan 22, 2025):

Thank you for your input. The root cause is specifically related to SQLAlchemy query result handling rather than environment or Docker configuration issues.

The error TypeError: 'Row' object has no attribute 'source_info' occurs because we're trying to access the model attributes directly from a Row object returned by session.execute(). Here's the specific issue and fix:

Current Implementation (causing 500 error):

data_source_bindings = session.execute(
    select(DataSourceOauthBinding).filter_by(
        tenant_id=current_user.current_tenant_id,
        provider="notion",
        disabled=False
    )
).all()

Fixed Implementation:

data_source_bindings = session.scalars(
    select(DataSourceOauthBinding).filter_by(
        tenant_id=current_user.current_tenant_id,
        provider="notion",
        disabled=False
    )
).all()

Key Differences:

  • session.scalars() returns model instances directly
  • This allows proper access to the source_info attribute
  • It correctly handles multiple records
  • No environment configuration changes are needed

I've tested this solution and confirmed it resolves the 500 error while maintaining proper access to the source_info attribute across all retrieved records.

@nagaihiroki-git commented on GitHub (Jan 22, 2025): Thank you for your input. The root cause is specifically related to SQLAlchemy query result handling rather than environment or Docker configuration issues. The error `TypeError: 'Row' object has no attribute 'source_info'` occurs because we're trying to access the model attributes directly from a Row object returned by `session.execute()`. Here's the specific issue and fix: ## Current Implementation (causing 500 error): ```python data_source_bindings = session.execute( select(DataSourceOauthBinding).filter_by( tenant_id=current_user.current_tenant_id, provider="notion", disabled=False ) ).all() ``` ## Fixed Implementation: ```python data_source_bindings = session.scalars( select(DataSourceOauthBinding).filter_by( tenant_id=current_user.current_tenant_id, provider="notion", disabled=False ) ).all() ``` ## Key Differences: - `session.scalars()` returns model instances directly - This allows proper access to the `source_info` attribute - It correctly handles multiple records - No environment configuration changes are needed I've tested this solution and confirmed it resolves the 500 error while maintaining proper access to the `source_info` attribute across all retrieved records.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7832