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: Return correct http error codes instead of 500. Fixes #9237 #9916

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

isubasinghe
Copy link
Member

@isubasinghe isubasinghe commented Oct 27, 2022

Signed-off-by: Isitha Subasinghe isitha@pipekit.io

Fixes #9237

Please do not open a pull request until you have checked ALL of these:

  • Create the PR as draft .
  • Run make pre-commit -B to fix codegen and lint problems.
  • Sign-off your commits (otherwise the DCO check will fail).
  • Use a conventional commit message (otherwise the commit message check will fail).
  • "Fixes #" is in both the PR title (for release notes) and this description (to automatically link and close the issue).
  • Add unit or e2e tests. Say how you tested your changes. If you changed the UI, attach screenshots.
  • Github checks are green.
  • Once required tests have passed, mark your PR "Ready for review".

If changes were requested, and you've made them, dismiss the review to get it reviewed again.

Sorry, something went wrong.

@isubasinghe isubasinghe changed the title fix: return http 400 instead of 500 fix: return http 400 instead of 500. Fixes #9237 Oct 28, 2022
@isubasinghe isubasinghe marked this pull request as ready for review October 28, 2022 00:53
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

This does not look like the correct approach to me. There is an error translator somewhere you could take a look at.

@stale
Copy link

stale bot commented Nov 23, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions.

@stale stale bot added the problem/stale This has not had a response in some time label Nov 23, 2022
@stale stale bot removed the problem/stale This has not had a response in some time label Nov 23, 2022
@isubasinghe isubasinghe marked this pull request as draft November 23, 2022 12:58
@isubasinghe isubasinghe changed the title fix: return http 400 instead of 500. Fixes #9237 [WIP] fix: return http 400 instead of 500. Fixes #9237 Nov 23, 2022
@isubasinghe isubasinghe force-pushed the fix-error-code branch 3 times, most recently from 472b8bd to 1c61f62 Compare November 25, 2022 01:18
@isubasinghe isubasinghe changed the title [WIP] fix: return http 400 instead of 500. Fixes #9237 fix: return http 400 instead of 500. Fixes #9237 Nov 25, 2022
@isubasinghe isubasinghe marked this pull request as ready for review November 25, 2022 01:18
@sarabala1979
Copy link
Member

@alexec Can you provide more information to @isubasinghe, So, he can refactor?

@isubasinghe
Copy link
Member Author

isubasinghe commented Nov 28, 2022

@sarabala1979 this is a refactor from the old one which Alex commented on. Every error goes through ToStatusError.
Here I try to extract an ArgoError and map it into a grpc error, failing that I try to extract a k8s error and map that into a grpc error. It is inspired from the error handler in

func (a *ArtifactServer) httpFromError(err error, w http.ResponseWriter) {
and this: https://github.com/grpc-ecosystem/grpc-gateway/blob/8952e38d5addd28308e29c272c696a578aa8ace8/runtime/errors.go#L36

In a general sense, the most relevant file here is just: https://github.com/argoproj/argo-workflows/pull/9916/files#diff-6ec3cdfd853ed9734ca0ba5e09bfc02c4a2ff21478a1d264ce3e4277e40f4c69

The others are just calling this.

@caelan-io
Copy link
Member

What are your thoughts @alexec ? Can we merge to close #9237?

Copy link
Member

@JPZ13 JPZ13 left a comment

Choose a reason for hiding this comment

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

Code looks great. Running well when tested locally. One quick nit, can you change the PR title to be something like fix: Return correct http error codes. Fixes #9237 or something similar?

@isubasinghe isubasinghe changed the title fix: return http 400 instead of 500. Fixes #9237 fix: Return correct http error codes. Fixes #9237 Nov 30, 2022
@isubasinghe isubasinghe requested a review from JPZ13 November 30, 2022 08:29
alexec
alexec previously requested changes Dec 1, 2022
Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

This looks great. I think maybe a couple more tests?

@stale
Copy link

stale bot commented Dec 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions.

@stale stale bot added the problem/stale This has not had a response in some time label Dec 31, 2022
@stale
Copy link

stale bot commented Jan 8, 2023

This issue has been closed due to inactivity. Feel free to re-open if you still encounter this issue.

@stale stale bot closed this Jan 8, 2023
@isubasinghe isubasinghe reopened this Jan 10, 2023
@stale stale bot removed the problem/stale This has not had a response in some time label Jan 10, 2023
Copy link
Member

@JPZ13 JPZ13 left a comment

Choose a reason for hiding this comment

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

Might have to run make codegen again to get the docs test to pass. I think this is due for a merge soon

@alexec alexec dismissed their stale review January 31, 2023 16:30

lack of bandwidth

Signed-off-by: Isitha Subasinghe <isitha@pipekit.io>
Signed-off-by: Isitha Subasinghe <isitha@pipekit.io>
Signed-off-by: Isitha Subasinghe <isitha@pipekit.io>
@sarabala1979 sarabala1979 enabled auto-merge (squash) February 2, 2023 17:26
@sarabala1979 sarabala1979 merged commit 898f064 into argoproj:master Feb 2, 2023
isubasinghe added a commit to isubasinghe/argo-workflows that referenced this pull request Feb 9, 2023
)

Signed-off-by: Isitha Subasinghe <isitha@pipekit.io>
GoshaDo pushed a commit to GoshaDo/argo-workflows that referenced this pull request Feb 9, 2023
)

Signed-off-by: Isitha Subasinghe <isitha@pipekit.io>
Signed-off-by: goshado <goshatoo@gmail.com>
@agilgur5 agilgur5 added the area/api Argo Server API label Sep 8, 2024
@agilgur5 agilgur5 changed the title fix: Return correct http error codes. Fixes #9237 fix: Return correct http error codes instead of 500. Fixes #9237 Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Argo Server API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflow API response failure due to RBAC restrictions returns 500 instead of 401/403
6 participants