Skip to content

fix: catch error when discovery_config is not a valid JSON #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

noctillion
Copy link
Contributor

catch error if config file is not a valid json preventing rendering failure

@noctillion noctillion requested a review from v-rocheleau April 11, 2025 18:00
try {
return rawText ? JSON.parse(rawText) : null;
} catch (e) {
// if the file is not a valid JSON
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a log

Copy link
Member

Choose a reason for hiding this comment

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

specifically, a console.error would be good

Comment on lines +137 to +139
return {
error: `${e}`,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no parsing errors this function returns a JSON.
If we also return a JSON when there is a parsing error, the user may think that what they get here is the actual content of the file.
One thing we could do is have this hook return 2 things: the JSON content, and an error message if any occurs.

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