Go to file
Ivan Fraixedes 8caa4c4557 satellite/console: Don't lose ErrValiation error class
There was a defined type (`validationErrors`) for gathering several
validation errors and classify them with the `ErrValdiation errs.Class`.

`errs.Combine` doesn't maintain the classes of the errors to combine,
for example

```
var myClass errs.Class = "My error class"

err1 := myClass.Wrap(erros.New("error 1"))
err2 := myClass.Wrap(erros.New("error 2"))
err3 := errors.New("error 3")

combinedErr := errs.Combine(err1, err2, err3)
myClass.Has(combinedErr) // It returns false

// Even only passing errors with a class and with the same one for all
// of them
combinedErr := errs.Combine(err1, err2)
myClass.Has(combinedErr) // It returns false
```

Hence `validationErrors` didn't return what we expected to return when
calling its `Combine` method.

This commit delete the type and it replaces by `errs.Group` when there
are more than one error, and wrapping the `errs.Group.Err` returned
error with `ErrValiation` error class.

The bug caused the HTTP API server to return a 500 status code as you
can seee in the following log message extracted from the satellite
production logs:

```
code: 500
error: "console service: validation: full name can not be empty; validation: Your password needs at least 6 characters long; validation: mail: no address"
errorVerbose: "console service: validation: full name can not be empty; validation: Your password needs at least 6 characters long; validation: mail: no address
        storj.io/storj/satellite/console.(*Service).CreateUser:593
        storj.io/storj/satellite/console/consoleweb/consoleapi.(*Auth).Register:250
        net/http.HandlerFunc.ServeHTTP:2047
        storj.io/storj/private/web.(*RateLimiter).Limit.func1:90
        net/http.HandlerFunc.ServeHTTP:2047
        github.com/gorilla/mux.(*Router).ServeHTTP:210
        storj.io/storj/satellite/console/consoleweb.(*Server).withRequest.func1:464
        net/http.HandlerFunc.ServeHTTP:2047
        net/http.serverHandler.ServeHTTP:2879
        net/http.(*conn).serve:1930"
message: "There was an error processing your request"
```

The issues was that not being classified with `ErrValidation` class it
was not picked by the correct switch branch of the
`consoleapi.Auth.getStatusCode` method which is in the call chain to
`consoleapi.Auth.Register` method when it calls
`console.Service.CreateUser` and returns an error.

These changes should return the appropriated HTTP status code (Bad
Request) when `console.Service.CreateUser` returns a validation error.

Returning the appropriated HTTP statsus code also makes not to show this
as an error in the server logs because the Bad Request sttatus code gets
logged with debug level.

Change-Id: I869ea85788992ae0865c373860fbf93a40d2d387
2022-02-28 11:00:56 +00:00
.github .github: add issue templates 2021-09-24 08:42:48 +00:00
certificate mod: use vendored base58 2022-01-31 15:54:33 +02:00
cmd satellite/metainfo: add feature flag for server side copy code 2022-02-24 10:43:49 +00:00
crashcollect crashcollect: removed redundant structure 2021-04-28 00:35:39 +03:00
docs docs/blueprints: server-side copy 2022-02-16 17:26:23 +00:00
installer/windows storj/storj: more domain changes 2021-04-15 20:51:43 +00:00
multinode multinode/nodes: pass Node entity to Add method instead of set of a parameters 2021-12-15 12:39:24 +00:00
private satellite/metainfo: add feature flag for server side copy code 2022-02-24 10:43:49 +00:00
resources cmd: add ca-certificates to Docker images (#3986) 2020-12-08 01:38:33 +01:00
satellite satellite/console: Don't lose ErrValiation error class 2022-02-28 11:00:56 +00:00
scripts satellite/metainfo: add feature flag for server side copy code 2022-02-24 10:43:49 +00:00
storage ci: Golangci lint v1.43.0 changes (#4307) 2021-12-09 20:49:48 +01:00
storagenode storagenode: check if QUIC is properly configured 2022-01-20 12:04:04 +00:00
testsuite satellite/web: change cli install flow to use uplink again 2022-02-18 16:46:30 +00:00
versioncontrol ci: fix lint errors 2021-05-17 13:37:31 +00:00
web satellite/web: change cli install flow to use uplink again 2022-02-18 16:46:30 +00:00
.dockerignore Forward-port release-alpha8 build script issues (#1726) 2019-04-09 23:01:10 -06:00
.gitattributes web/: add check for change to eslint import 2021-12-21 15:59:23 +00:00
.gitignore private/testplanet: support writing monitoring spans 2021-09-30 09:03:35 +03:00
.gitreview add config file for git review usage 2021-10-14 18:01:30 +00:00
CODE_OF_CONDUCT.md Adding CODE_OF_CONDUCT to storj/storj repo (#779) 2018-12-07 15:10:02 -05:00
CONTRIBUTING.md go.mod: update to minimum supported go version (#4239) 2021-10-22 21:12:13 +02:00
go.mod deps: upgrade storj.io/common 2022-02-16 18:59:19 +00:00
go.sum deps: upgrade storj.io/common 2022-02-16 18:59:19 +00:00
Jenkinsfile scripts,Jenkinsfile,Makefile: upload binaries to drafted github release 2021-12-21 13:55:38 +00:00
Jenkinsfile.public private/testplanet: use info level logs in jenkins 2022-02-10 11:47:06 -06:00
LICENSE license code with agplv3 (#126) 2018-07-05 10:24:26 -04:00
MAINTAINERS.md satellite-ui: update wizard to instruct uplinkng usage 2022-02-01 18:22:04 +00:00
Makefile final touches 2022-02-21 13:08:48 +02:00
monkit.lock satellite/audit: log error and increment metric if shares cannot be verified 2021-08-27 15:28:16 +00:00
proto.lock multinode/payouts: paystub extended with disposed 2021-06-01 16:28:20 +00:00
README.md Update README.md (#4320) 2021-12-22 14:12:58 +01:00

Storj V3 Network

Go Report Card Go Doc Coverage Status

Storj is building a decentralized cloud storage network. Check out our white paper for more info!


Storj is an S3-compatible platform and suite of decentralized applications that allows you to store data in a secure and decentralized manner. Your files are encrypted, broken into little pieces and stored in a global decentralized network of computers. Luckily, we also support allowing you (and only you) to retrieve those files!

Table of Contents

Contributing to Storj

All of our code for Storj v3 is open source. If anything feels off, or if you feel that some functionality is missing, please check out the contributing page. There you will find instructions for sharing your feedback, building the tool locally, and submitting pull requests to the project.

A Note about Versioning

While we are practicing semantic versioning for our client libraries such as uplink, we are not practicing semantic versioning in this repo, as we do not intend for it to be used via Go modules. We may have backwards-incompatible changes between minor and patch releases in this repo.

Start using Storj

Our wiki has documentation and tutorials. Check out these three tutorials:

License

This repository is currently licensed with the AGPLv3 license.

For code released under the AGPLv3, we request that contributors sign our Contributor License Agreement (CLA) so that we can relicense the code under Apache v2, or other licenses in the future.

Support

If you have any questions or suggestions please reach out to us on our community forum or file a ticket at https://support.storj.io/.