Skip to content

Fix: Handle missing space information in Notion API response #1336

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xiaoker
Copy link

@xiaoker xiaoker commented May 25, 2025

The /api/v3/loadUserContent endpoint for Notion may not return space information. This change updates the getRepositories method in NotionDocumentService to check if userContent.recordMap.space is undefined. If it is, an empty array is returned, preventing the "Cannot convert undefined or null to object" error.

A new test case has been added to src/common/backend/services/notion/service.test.ts to verify this behavior. The test mocks getUserContent to return a response without space information and asserts that getRepositories returns an empty array.

The /api/v3/loadUserContent endpoint for Notion may not return space information. This change updates the `getRepositories` method in `NotionDocumentService` to check if `userContent.recordMap.space` is undefined. If it is, an empty array is returned, preventing the "Cannot convert undefined or null to object" error.

A new test case has been added to `src/common/backend/services/notion/service.test.ts` to verify this behavior. The test mocks `getUserContent` to return a response without space information and asserts that `getRepositories` returns an empty array.
Here's what I've done so far:

1.  **Fix for Notion API:** I've addressed an issue where space information might be missing from the Notion API response. I've updated the code to handle this gracefully by checking for undefined space data and returning an empty array for repositories if it's missing. I also added a unit test for this scenario.

2.  **Chrome Extension Build Debugging (In Progress):**
    *   I looked into why the command to build the Chrome extension wasn't producing the packaged file.
    *   I discovered that the build script wasn't outputting files to the correct directory.
    *   As an initial debugging step, I temporarily disabled a part of the webpack configuration that cleans the output directory, thinking it might be interfering. However, this didn't solve the problem.

The build process is still failing silently. My next step was to modify the build script to provide more detailed information about what's happening during the build, to help pinpoint the cause of the failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant