Skip to content

Fix/propagate errors for i18n entries#7773

Open
sempostma wants to merge 3 commits intodecaporg:mainfrom
laikacms:fix/propagate-errors-for-i18n-entries
Open

Fix/propagate errors for i18n entries#7773
sempostma wants to merge 3 commits intodecaporg:mainfrom
laikacms:fix/propagate-errors-for-i18n-entries

Conversation

@sempostma
Copy link
Copy Markdown
Contributor

Summary

On 18n enabled websites, when for some reason the backend fails to retrieve any entries, for example because their is no internet connection: The default entry will be set to undefined since the values array is empty. This causes the following line to throw since it's accessing defaultEntry.value where defaultEntry is undefined.

The following PR should fix this by not allowing an empty list to be passed to the mergeValues function in the first place and properly propagate errors.

Test plan

  • Setup Decap CMS with i18n
  • Modify decap-server to throw an error in the entry retrieval code

Checklist

Please add a x inside each checkbox:

@sempostma sempostma requested a review from a team as a code owner April 2, 2026 15:22
Copy link
Copy Markdown
Contributor

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sempostma, I have one comment about how to fix the TS error, but overall this change sounds good to me.

}[];
const nonNullValues = entryValuesResults
.map(e => (e.status === 'fulfilled' ? e.value : undefined))
.filter(e => e !== undefined);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the current version of TypeScript here doesn't infer the filter removing undefined from the possible values. I think the easier fix is to just bring back the type predicate.

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.

2 participants