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

Neon API requests handling error #2159

Closed
kislerdm opened this issue Jul 26, 2022 · 2 comments
Closed

Neon API requests handling error #2159

kislerdm opened this issue Jul 26, 2022 · 2 comments
Assignees
Labels
c/console Component: console t/bug Issue Type: Bug t/user_request Issue type: feature or bug report from the real cloud user
Milestone

Comments

@kislerdm
Copy link

kislerdm commented Jul 26, 2022

Problem description

Some Neon API end-points return incorrect responses. The are not in line with the documentation, neither are they correct from the logical point of view.

How to reproduce

Please find the examples illustrating API calls to retrieve data for the project which does not exist.

curl -I -X GET -H "Authorization: Bearer ${NEON_API_KEY}" "https://console.neon.tech/api/v1/projects/foo"
HTTP/2 200 
date: Tue, 26 Jul 2022 10:19:14 GMT
content-length: 0

curl -I -X GET -H "Authorization: Bearer ${NEON_API_KEY}" "https://console.neon.tech/api/v1/projects/foo/query/saved"    
HTTP/2 201 
date: Tue, 26 Jul 2022 10:21:35 GMT
content-type: application/json; charset=utf-8
content-length: 2

 curl -I -X GET -H "Authorization: Bearer ${NEON_API_KEY}" "https://console.neon.tech/api/v1/projects/foo/operations"
HTTP/2 200 
date: Tue, 26 Jul 2022 10:23:16 GMT
content-type: application/json; charset=utf-8
content-length: 2

Expected behaviour

The following response is expected to be in line with the API documentation if requested resource is missing.

Status code: 404.
Content format:

{
  "code": "string",
  "message": "string"
}
@kislerdm kislerdm changed the title Bug in Rest API requests handling Neon API requests handling error Jul 26, 2022
kislerdm pushed a commit to kislerdm/neon-sdk-go that referenced this issue Jul 26, 2022
Signed-off-by: Dmitry Kisler <dmitry.kisler@olx.com>
@ololobus ololobus added c/console Component: console t/user_request Issue type: feature or bug report from the real cloud user labels Jul 26, 2022
@ololobus ololobus added this to the 2022/08 milestone Jul 26, 2022
@ololobus ololobus added the t/bug Issue Type: Bug label Jul 26, 2022
@ololobus ololobus assigned ololobus and antonyc and unassigned antonyc and ololobus Jul 26, 2022
@stepashka stepashka modified the milestones: 2022/08, 2022/10 Oct 27, 2022
@ololobus
Copy link
Member

ololobus commented Nov 1, 2022

@antonyc do we have the same problem in v2?

@antonyc
Copy link
Member

antonyc commented Nov 2, 2022

In API v2 we are not 100% protected from returning 200 on error. If there is a bug in handling an error in the controller code, we will get the same result in API v2. On the other hand, it's highly unlikely to have such an error in API v2 if we're always handling the error in the form of

if err != nil {
  return err
}

and do not try to handle errors in any other way.

In API v2 we're 100% protected from returning unexpected status codes on successful handling, we're 100% compliant with the spec here.

Specifically tested these endpoints. Only the GET ../projects/foo/query/saved still suffers from this rather strange behavior, and it happened to be compliant with the spec (!). Will fix.

➜  cloud git:(main) ✗ curl -I -X GET -H "Authorization: Bearer ${NEON_API_KEY}" "https://console.neon.tech/api/v1/projects/foo"
HTTP/2 404
date: Wed, 02 Nov 2022 12:36:59 GMT
content-type: application/json; charset=utf-8
content-length: 33

➜  cloud git:(main) ✗ curl -I -X GET -H "Authorization: Bearer ${NEON_API_KEY}" "https://console.neon.tech/api/v1/projects/foo/query/saved"
HTTP/2 201
date: Wed, 02 Nov 2022 12:37:26 GMT
content-type: application/json; charset=utf-8
content-length: 2

➜  cloud git:(main) ✗ curl -I -X GET -H "Authorization: Bearer ${NEON_API_KEY}" "https://console.neon.tech/api/v1/projects/foo/operations"
HTTP/2 404
date: Wed, 02 Nov 2022 12:37:44 GMT
content-type: application/json; charset=utf-8
content-length: 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/console Component: console t/bug Issue Type: Bug t/user_request Issue type: feature or bug report from the real cloud user
Projects
None yet
Development

No branches or pull requests

4 participants