Skip to content

Display API message on not found errors#1935

Merged
david-crespo merged 2 commits into
mainfrom
not-found-error
Feb 2, 2024
Merged

Display API message on not found errors#1935
david-crespo merged 2 commits into
mainfrom
not-found-error

Conversation

@david-crespo

Copy link
Copy Markdown
Collaborator

We have had multiple people raise the issue that when they tried to create an instance without a default IP pool in their silo, it was almost impossible to figure out what the problem was.

oxidecomputer/omicron#4864
oxidecomputer/omicron#4954

I improved the API error message in oxidecomputer/omicron#4880, but this morning I figured out that in both cases, they were using the web console, and it did not matter what the API error was because we only show OBJECT NOT FOUND on instance create when we get a 404 back.

} else if (code === 'ObjectNotFound') {
message = 'Object not found'

So this PR changes that behavior so that the client-side error object we pass around contains the error message from the API. As I mentioned here, it might be nice to change the error code from 404 to something else, but I really think this PR gets us 80% of the way there.

My only concern here is that there might be some spots where "Object not found" was nicer than the API error and made sense in context, but now we will be displaying the API error. But hopefully that can't be too bad, since the API messages are all designed to be human readable and helpful.

Before

image

After

image

@vercel

vercel Bot commented Feb 2, 2024

Copy link
Copy Markdown

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

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Feb 2, 2024 6:18pm

Comment thread libs/api/errors.ts
message = 'Action not authorized'
} else if (code === 'ObjectNotFound') {
message = 'Object not found'
message = capitalize(resp.data.message)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the entire change. Everything else is tests.

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.

1 participant