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

Add useful body text to error responses from /database/publish route #315

Closed
2 tasks
gefjon opened this issue Sep 25, 2023 · 2 comments
Closed
2 tasks

Add useful body text to error responses from /database/publish route #315

gefjon opened this issue Sep 25, 2023 · 2 comments
Assignees

Comments

@gefjon
Copy link
Contributor

gefjon commented Sep 25, 2023

At some point (probably introducing cloud-next), we merged a regression in the HTTP API's error reporting, where now any errors in /database/publish will return a 500 with no body text. The CLI uses the response body text to print its error, so we get such gems as:

info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
   Compiling bitcraft-spacetimedb v0.1.0 (C:\ClockworkLabs\BitCraft\packages\game)
    Finished release [optimized] target(s) in 1m 02s
checking crate with spacetimedb's clippy configuration
   Compiling bitcraft-spacetimedb v0.1.0 (C:\ClockworkLabs\BitCraft\packages\game)
    Finished dev [unoptimized + debuginfo] target(s) in 19.43s
Error:

I also notice that we return BAD_REQUEST for invalid credentials, rather than UNAUTHORIZED.

For at least the /database/publish route, and ideally the entire HTTP API surface:

  • Replace auth_or_bad_request with auth_or_unauth.
  • Replace log_and_500 with specific error response tuples of (STATUS_CODE, "Message"), where STATUS_CODE is an appropriate HTTP error code, and "Message" is a string describing what went wrong. The CLI will show that string to users on failure.
@kim
Copy link
Contributor

kim commented Sep 25, 2023

Is this just due to bad merges?

@gefjon
Copy link
Contributor Author

gefjon commented Sep 30, 2023

Closed by Kim's linked PR and #338 .

@gefjon gefjon closed this as completed Sep 30, 2023
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

No branches or pull requests

2 participants