-
Notifications
You must be signed in to change notification settings - Fork 380
fix(api): resolve panic when storage incentives disabled #5150
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
Conversation
nugaon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems good just my 2 cents
pkg/api/router.go
Outdated
| func (s *Service) checkStorageIncentivesAvailability(handler http.Handler) http.Handler { | ||
| return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| if s.redistributionAgent == nil { | ||
| jsonhttp.NotImplemented(w, "Storage incentives are disabled. This endpoint is unavailable.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, it is implemented, it is more like a 404 Not Found or a 403 Forbidden. I would simply go with 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have used this status code when Swap is disabled and Chequebook is disabled, which was done in this PR. But we can change it to 403 Forbidden, because route does exit, but it is disabled on server side. In that case we should change this for all 3 endpoints to have the same behaviour.
@janos, @nugaon any opion on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
403 is also fine from my side on all similar places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests still need to be adjusted: https://github.com/ethersphere/bee/actions/runs/16437874357/job/46453779979?pr=5150
Checklist
Description
Adds handler that checks if redistributionAgent is initialized.
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
Redistribution handler panics when called with storage incentives disabled #5143
Screenshots (if appropriate):