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 admin API error messages not showing in client #4564

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

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Feb 14, 2025

Problem

return { success: false, error: "Oh no!" } was being used in a few places in our API, but the admin client didn't understand what to do with that response.

image

Fix

I grep'd return { in the API folder, and updated any instance of the non-working pattern with throw new JsonError( instead.

To test

Check this branch out, go to http://localhost:3030/admin/charts/create and click "Create Draft"
The error that throws (due to missing data) will render correctly in the client.

@ikesau ikesau requested a review from danyx23 February 14, 2025 18:39
@ikesau ikesau self-assigned this Feb 14, 2025
@owidbot
Copy link
Contributor

owidbot commented Feb 14, 2025

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-api-errors

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2025-02-14 18:54:33 UTC
Execution time: 1.16 seconds

const json = await response.json()

if (verifySuccess) {
expect(response.status).toBe(200)
Copy link
Member Author

@ikesau ikesau Feb 14, 2025

Choose a reason for hiding this comment

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

tests would now fail without making this change, but it kind of begs the question: why have success = true and status = 200

🤔

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