Skip to content

fix: remove attempt to get a more comprehensive error#7270

Closed
martinjagodic wants to merge 14 commits intomainfrom
handle-duplicate-field
Closed

fix: remove attempt to get a more comprehensive error#7270
martinjagodic wants to merge 14 commits intomainfrom
handle-duplicate-field

Conversation

@martinjagodic
Copy link
Copy Markdown
Member

Closes #7262

attempt was used to better handle the function, but it obtused the error so it was not clear which frontamtter field was duplicated.

@martinjagodic martinjagodic requested a review from a team as a code owner August 27, 2024 13:36
@github-actions github-actions Bot added the type: bug code to address defects in shipped code label Aug 27, 2024
@martinjagodic martinjagodic removed the type: bug code to address defects in shipped code label Aug 27, 2024
@martinjagodic martinjagodic requested review from demshy and removed request for a team August 27, 2024 13:58
demshy
demshy previously approved these changes Aug 30, 2024
@martinjagodic
Copy link
Copy Markdown
Member Author

The collection list view now displays the error toast, but does not load any entries if one is corrupted. A fix should be somewhere in backend.ts. formattedEntries and filteredEntries should return the non-corrupted entries, but still trigger the error.

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.

One small nit from me

Comment on lines +634 to +645
response.errors?.forEach(error => {
dispatch(
addNotification({
message: {
details: error,
key: 'ui.toast.duplicateFrontmatterKey',
},
type: 'warning',
dismissAfter: 8000,
}),
);
});
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.

My only worry is if there's a ton of errors at one time. Maybe we should aggregate it?

Also, the key is ui.toast.duplicateFrontmatterKey, but from what I understood the code will also catch other types of parsing issues, so maybe the name should be more generic? Like ui.toast.entryParseErrors

Suggested change
response.errors?.forEach(error => {
dispatch(
addNotification({
message: {
details: error,
key: 'ui.toast.duplicateFrontmatterKey',
},
type: 'warning',
dismissAfter: 8000,
}),
);
});
if (response.errors?.length) {
dispatch(addNotification({
message: {
details: response.errors.join('\n'),
key: 'ui.toast.entryParseErrors',
},
type: 'warning',
dismissAfter: 8000,
}));
}

@martinjagodic
Copy link
Copy Markdown
Member Author

closing as this is fixed in #7679

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.

Throw better error on duplicate frontmatter key

3 participants