Skip to content

fix: return JSON instead of plain text on theme-comparison error#200

Merged
SamXop123 merged 1 commit into
SamXop123:mainfrom
bh462007:fix/json-error-response
Jun 17, 2026
Merged

fix: return JSON instead of plain text on theme-comparison error#200
SamXop123 merged 1 commit into
SamXop123:mainfrom
bh462007:fix/json-error-response

Conversation

@bh462007

Copy link
Copy Markdown
Contributor

Summary

This PR fixes an inconsistency in the error response format of the theme comparison route.

Previously, internal server errors in theme-comparison.route.js returned a plain text response using .send(), while the rest of the API follows a JSON-based response structure for both successful and failed requests. This could lead to inconsistent handling on the client side and makes the API contract less predictable.

Closes #193

Changes Made

src/routes/theme-comparison.route.js

  • Replaced the plain text error response with a structured JSON response
  • Preserved the existing error message content
  • Ensured the response is returned with the correct application/json content type

Example

Before

res.status(500).send('Error rendering theme preview');

After

res.status(500).json({
  error: 'Error rendering theme preview'
});

Why This Change?

  • Keeps API responses consistent across the application
  • Makes error handling more predictable for API consumers
  • Returns the appropriate JSON content type for error responses
  • Aligns this route with existing API response patterns

Testing

There are currently no automated tests covering this route.

Manually verified that:

  • The route still returns HTTP 500 on internal errors
  • The error message content remains unchanged
  • The response body is now returned as structured JSON
  • The response uses the application/json content type

Type of Change

  • Bug fix

Copilot AI review requested due to automatic review settings June 17, 2026 12:42
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@bh462007 is attempting to deploy a commit to the Dot_NotSam's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the error response format for the theme preview endpoint to return JSON instead of plain text on server errors.

Changes:

  • Switches the 500 response from send() with a string to json() with an error field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} catch (error) {
console.error('Theme preview render failed:', error.message);
res.status(500).send('Error rendering theme preview');
res.status(500).json({ error: 'Error rendering theme preview'});
@SamXop123 SamXop123 merged commit 5da2e16 into SamXop123:main Jun 17, 2026
2 of 3 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @bh462007! 🎉

Your pull request has been successfully merged into samdev-pulse! Thank you so much for your valuable contribution and effort. Every single improvement helps make samdev-pulse a better profile experience for everyone! 🙌

🚀 What's Next?

  • Keep the momentum going! Feel free to browse through our open Issues and grab another one that interests you!
  • Support the Project: If you enjoyed contributing to samdev-pulse, please take a second to star our repository! It helps increase the project's visibility and supports our community. ⭐

💬 Stay Connected:
Have any questions, want feedback, or just want to discuss further contributions? Feel free to reach out directly to the maintainer on Discord: dot_notsam

Thank you again, and keep up the amazing work! 💻✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: /api/theme-comparison returns plain text on internal server errors instead of JSON

3 participants