Skip to content

Commit

Permalink
Fix customization not found (#2734)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge authored Jan 14, 2025
1 parent 5664e5a commit 1fcc807
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-comics-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gitbook': patch
---

Fix errors from customization not found
18 changes: 15 additions & 3 deletions packages/gitbook/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,9 +850,21 @@ export async function getSiteData(
const spaces =
siteSpaces ?? (sections ? parseSpacesFromSiteSpaces(sections.section.siteSpaces) : []);

const customization = await getActiveCustomizationSettings(
pointer.siteSpaceId ? customizations.siteSpaces[pointer.siteSpaceId] : customizations.site,
);
const settings = (() => {
if (pointer.siteSpaceId) {
const siteSpaceSettings = customizations.siteSpaces[pointer.siteSpaceId];
if (siteSpaceSettings) {
return siteSpaceSettings;
}
// We got the pointer from an API and customizations from another.
// It's possible that the two are unsynced leading to not found customizations for the space.
// It's better to fallback on customization of the site that displaying an error.
console.warn('Customization not found for site space', pointer.siteSpaceId);
}
return customizations.site;
})();

const customization = await getActiveCustomizationSettings(settings);

return {
customization,
Expand Down

0 comments on commit 1fcc807

Please sign in to comment.