Skip to content

fix: handle Notion API's nested response format change#432

Open
amaran-th wants to merge 1 commit intomorethanmin:mainfrom
amaran-th:fix/notion-api-response-format
Open

fix: handle Notion API's nested response format change#432
amaran-th wants to merge 1 commit intomorethanmin:mainfrom
amaran-th:fix/notion-api-response-format

Conversation

@amaran-th
Copy link

Description

Fixes an issue where the main page shows "Nothing!" with 0 tags due to a change in the Notion API response format.

Problem

The Notion API response structure for block and collection has changed:

  • Before: block[id].value → block data directly ({ type, properties, created_time, ... })
  • After: block[id].value{ value: { type, properties, created_time, ... }, role: ... }

This causes rawMetadata.type in getPosts() to be undefined, failing the type check and returning an empty array [].

Solution

Uses ?.value ?? fallback pattern to support both the old and new response formats.

  • src/apis/notion-client/getPosts.ts: Unwrap nested collection and block values
  • src/libs/utils/notion/getPageProperties.ts: Unwrap nested block value

Related tickets

#425

PR Checklist

@vercel
Copy link

vercel bot commented Feb 9, 2026

Someone is attempting to deploy a commit to the untilled Team on Vercel.

A member of the Team first needs to authorize it.

@PurpleSand123
Copy link

Thanks this solved my problem

@c-jeongyyun
Copy link

Please check src/libs/utils/notion/customMapImageUrl.ts too. I had trouble fetching thumbnail images that were uploaded directly to Notion.

I fixed like this:

image

@amaran-th
Copy link
Author

@c-jeongyyun
Thank you for the comments!
This PR already addresses that. In getPageProperties.ts, the block data passed to customMapImageUrl is now properly unwrapped:

const blockEntry = block?.[id]?.value as any
const blockValue = blockEntry?.value ?? blockEntry // ← unwrapped block data
// ...
case "file": {
  const Block = blockValue // ← passes unwrapped data with correct `id` and `parent_table`
  const newurl = customMapImageUrl(url, Block)
}

Could you check if thumbnail images work correctly with this fix applied? If the issue persists, it may be a separate problem worth investigating.

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.

3 participants