Skip to content
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

fix: add a link to a github issue when themes are missing #37

Merged
merged 2 commits into from Nov 29, 2023

Conversation

thomasdavis
Copy link
Member

@thomasdavis thomasdavis commented Nov 29, 2023

Fix #38

Summary by CodeRabbit

  • Bug Fixes

    • Corrected typo in error messages to accurately reflect "not supported formatter."
    • Improved error handling for missing themes with informative messages and resource links.
    • Updated HTTP status codes for specific errors to enhance API response accuracy.
  • Documentation

    • Clarified that there are no changes to function signatures or global structures.

Copy link

vercel bot commented Nov 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jsonresume-org-homepage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 29, 2023 9:50am
jsonresume-org-registry ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 29, 2023 9:50am

Copy link
Contributor

coderabbitai bot commented Nov 29, 2023

Walkthrough

The recent updates focus on improving error handling within an API. Error messages have been clarified, and HTTP status codes adjusted to better reflect the nature of the errors. A specific case for a missing theme has been addressed, providing users with a helpful link to report or request themes on GitHub.

Changes

File Path Change Summary
.../[payload].js Corrected error message wording, added custom error message for "theme-missing" with a GitHub issue link, and updated HTTP status codes for various errors.
.../formatters/template.js Implemented error handling for missing theme renderer.

🐇✨
To the code we hop and leap,
Errors caught, no more we weep.
With messages clear and guide in hand,
Our code now speaks, as we had planned. 🌟📜


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@thomasdavis
Copy link
Member Author

@levino approval on this one is kinda of urgent

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 257e367 and 6c2b30e.
Files selected for processing (2)
  • apps/registry/pages/api/[payload].js (2 hunks)
  • apps/registry/pages/api/formatters/template.js (1 hunks)
Additional comments: 3
apps/registry/pages/api/[payload].js (1)
  • 54-58: The error message correction from "not supported formatted" to "not supported formatter" improves clarity and is consistent with the summary.
apps/registry/pages/api/formatters/template.js (2)
  • 52-54: The error handling for a missing theme renderer is correctly implemented by throwing an error with the message 'theme-missing'. This aligns with the summary provided.

  • 58-58: The return structure of the format function remains consistent with the previous version, as indicated by the summary.

Comment on lines 176 to 183
if (e.message === 'theme-missing') {
return res
.status(200)
.send(
failMessage(
'This theme is currently unsupported. Please visit this Github issue to request it https://github.com/jsonresume/jsonresume.org/issues/36 (unfortunately we have recently (11/2023) disabled a bunch of legacy themes due to critical flaws in them, please request if you would like them back.)'
)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of a custom error message for the "theme-missing" error is a good enhancement for user feedback. However, the HTTP status code 200 is not appropriate for an error condition. Consider using a 4xx status code to indicate client-side errors.

- .status(200)
+ .status(404) // or another appropriate 4xx error code

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (e.message === 'theme-missing') {
return res
.status(200)
.send(
failMessage(
'This theme is currently unsupported. Please visit this Github issue to request it https://github.com/jsonresume/jsonresume.org/issues/36 (unfortunately we have recently (11/2023) disabled a bunch of legacy themes due to critical flaws in them, please request if you would like them back.)'
)
);
if (e.message === 'theme-missing') {
return res
.status(404) // or another appropriate 4xx error code
.send(
failMessage(
'This theme is currently unsupported. Please visit this Github issue to request it https://github.com/jsonresume/jsonresume.org/issues/36 (unfortunately we have recently (11/2023) disabled a bunch of legacy themes due to critical flaws in them, please request if you would like them back.)'
)
);

Comment on lines 186 to 188
return res
.status(200)
.send(
Copy link
Contributor

Choose a reason for hiding this comment

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

The HTTP status code for the generic error message should also reflect an error condition. Consider using a 4xx or 5xx status code to indicate client or server errors, respectively.

- .status(200)
+ .status(500) // or another appropriate error code

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
return res
.status(200)
.send(
return res
.status(500) // or another appropriate error code
.send(

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6c2b30e and d5f4df5.
Files selected for processing (1)
  • apps/registry/pages/api/[payload].js (4 hunks)
Additional comments: 4
apps/registry/pages/api/[payload].js (4)
  • 56-57: The error message has been correctly updated to 'not supported formatter', which is more accurate and aligns with the summary.

  • 123-123: The HTTP status code for the error message 'Cannot fetch gist, no idea why' has been correctly updated to 400, indicating a bad request, which is more appropriate than the previous 200 status code.

  • 135-135: The HTTP status code for the error message 'Validation failed' has been correctly updated to 400, which is the correct status code for validation errors.

  • 176-181: The new conditional block for the 'theme-missing' error has been added, providing a detailed message with a link to a Github issue for theme requests. This is a helpful addition for users encountering this error.

@levino
Copy link
Collaborator

levino commented Nov 29, 2023

Please see #38 (comment) If you get impatient, let me know and I will approve anyhow.

@levino
Copy link
Collaborator

levino commented Nov 29, 2023

@thomasdavis You can now "override" the branch protection rules and merge as you please. There should be a checkbox with a red warning text just above the "merge button". This is so you do not become blocked if I am absent etc. I suggest to still only use it when it is really necessary ("emergency").

@levino
Copy link
Collaborator

levino commented Nov 29, 2023

I would also add a test to try to open the site with a non-working theme and see that it returns an error code and check that the message contains expected strings (like "github issue" or something).

@thomasdavis thomasdavis merged commit 02606ab into master Nov 29, 2023
8 checks passed
@thomasdavis thomasdavis deleted the fix/missing-themes branch November 29, 2023 10:25
@thomasdavis
Copy link
Member Author

@levino good feedback. just merging for now so i can collect the errors of the themes that are missing. but will add the test, and move to a theme request template later today

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.

enable users to ask for support of specific themes
2 participants