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

Improve bad arguments error to provide a reason #390

Open
rolznz opened this issue Jun 27, 2023 · 2 comments
Open

Improve bad arguments error to provide a reason #390

rolznz opened this issue Jun 27, 2023 · 2 comments

Comments

@rolznz
Copy link
Contributor

rolznz commented Jun 27, 2023

If an invalid request is provided it would be nice to return to the caller why the arguments were bad rather than just "bad arguments".

I am not sure of the security implications here.

https://github.com/getAlby/lndhub.go/blob/main/lib/responses/errors.go#L25

@lujakob
Copy link

lujakob commented Jul 5, 2023

@kiwiidb this issue doesn't seem to complex to solve. Can I give it a try?

My suggestion is to create a method that returns the BadArgumentsError and can be passed an argument to append to the already available property Message: "Bad arguments",

I would suggest to just pass the same string that is passed to Errorf

c.Logger().Errorf("Failed to load addinvoice request body: %v", err)
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)

All cases should be checked if this string contains data that should not be revealed.

Any concerns? Am I missing something?

@kiwiidb
Copy link
Contributor

kiwiidb commented Aug 1, 2023

Should be good, please make a PR including an integration test and a some examples of the error JSON's in the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants