fix: bypass Notion image proxy for external bookmark URLs#306
fix: bypass Notion image proxy for external bookmark URLs#306
Conversation
…df-8.0.2 chore(deps): bump react-pdf from 8.0.0 to 8.0.2
…norepo deps: Update typescript-eslint monorepo to v8 (major)
deps: Update dependency react-pdf to v9
deps: Update dependency eslint-config-next to v15
deps: Update dependency @vitest/coverage-v8 to v2
deps: Update all non-major dependencies
- Change assert to with for JSON imports - Add vite-plugin-dts to root devDependencies - Fix duplicate code from bad merge in context.tsx and search-dialog.tsx - Add missing imports in search-dialog.tsx
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Fix ESLint 9.x compatibility by adding ESLINT_USE_FLAT_CONFIG=false Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Keep vite-plugin-dts from branch - Update vite and vitest to latest versions - Fix ESLint 9.x compatibility by adding ESLINT_USE_FLAT_CONFIG=false Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…push-on-commit Add push option to export CLI
…-reduce-build-size Switch nutils to vite build
…-to-notion.so/pageid Handle cross-space PageLink
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…okmark images - External HTTPS URLs now bypass the notion.so image proxy, fixing broken bookmark covers - Added onError handling to bookmark icon and cover images to hide them on load failure - Added tests for defaultMapImageUrl external URL handling Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
📝 WalkthroughWalkthroughAdds image load error handling and a LazyImage onError prop, tightens image URL proxying to skip external HTTPS hosts, bumps a dev dependency, updates Vite rollup externals, and adds tests for image URL mapping. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
collection.schema can be undefined when Notion API returns incomplete data. Add optional chaining to all collection.schema access points to prevent crash during SSR/SSG rendering.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/nreact/src/third-party/collection-view-table.tsx`:
- Around line 70-74: The loop that renders table body cells reads schema =
collection.schema?.[property] and later dereferences schema.type causing a
TypeError when collection.schema is undefined; add a guard like in
collection-view-list.tsx so any access to schema.type first ensures schema is
truthy (e.g., use const schema = collection.schema?.[property] ?? null and skip
or use default when schema is null) inside the body-rendering loop (the code
that iterates over properties and reads schema.type), and ensure the
table_properties/properties path handles missing collection.schema by treating
missing schema entries as null/empty before accessing .type.
| properties = [{ property: 'title' }].concat( | ||
| Object.keys(collection.schema) | ||
| Object.keys(collection.schema || {}) | ||
| .filter(p => p !== 'title') | ||
| .map(property => ({ property })) | ||
| ) |
There was a problem hiding this comment.
Incomplete fix — collection.schema || {} still leads to NPE at line 126 via the else branch.
When collection.schema is undefined and collectionView.format?.table_properties is falsy (the else branch), the fix changes Object.keys(collection.schema) (which threw immediately) into Object.keys({}), yielding []. The concat at line 70 still produces properties = [{ property: 'title' }]. The body-rendering loop then reaches line 112 where schema = collection.schema?.title → undefined, and line 126 dereferences schema.type → TypeError.
The crash is relocated from Object.keys() to schema.type, not eliminated.
Add a guard consistent with the pattern already used in collection-view-list.tsx (line 54):
🛡️ Proposed fix — guard before `schema.type` dereference in the body loop
{properties.map(p => {
const schema = collection.schema?.[p.property]
const block = recordMap.block[blockId]?.value
const data = block?.properties?.[p.property]
const isTitle = p.property === 'title'
const style: React.CSSProperties = {}
if (p.width) style.width = p.width
else if (isTitle) style.width = 280
else style.width = 200
+
+ if (!schema) return null
return (
<div
key={p.property}
className={`notion-table-cell ${`notion-table-cell-${schema.type}`}`}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/nreact/src/third-party/collection-view-table.tsx` around lines 70 -
74, The loop that renders table body cells reads schema =
collection.schema?.[property] and later dereferences schema.type causing a
TypeError when collection.schema is undefined; add a guard like in
collection-view-list.tsx so any access to schema.type first ensures schema is
truthy (e.g., use const schema = collection.schema?.[property] ?? null and skip
or use default when schema is null) inside the body-rendering loop (the code
that iterates over properties and reads schema.type), and ensure the
table_properties/properties path handles missing collection.schema by treating
missing schema entries as null/empty before accessing .type.
ef98f3f to
751847d
Compare
Summary
notion.so/image/proxy, fixing broken bookmark cover/icon imagesonErrorhandling to bookmark images inLazyImageto hide broken images gracefullydefaultMapImageUrlexternal URL handlingTest plan
map-image-url.test.tstests pass🤖 Generated with Claude Code
Summary by CodeRabbit