Improve error messages (#10843)

- Fix: "bytes" should be less than %!s(int=131072) message
- Also add a missing openapi type that was throwing warnings
This commit is contained in:
Jim Kalafut 2021-02-11 19:51:12 -08:00 committed by GitHub
parent a8d2e6e350
commit 42bae71806
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -64,14 +64,14 @@ func (b *backend) pathRandomWrite(ctx context.Context, req *logical.Request, d *
}
if bytes > maxBytes {
return logical.ErrorResponse(`"bytes" should be less than %s`, maxBytes), nil
return logical.ErrorResponse(`"bytes" should be less than %d`, maxBytes), nil
}
switch format {
case "hex":
case "base64":
default:
return logical.ErrorResponse(fmt.Sprintf("unsupported encoding format %s; must be \"hex\" or \"base64\"", format)), nil
return logical.ErrorResponse("unsupported encoding format %q; must be \"hex\" or \"base64\"", format), nil
}
randBytes, err := uuid.GenerateRandomBytes(bytes)

View file

@ -575,6 +575,9 @@ func convertType(t FieldType) schemaType {
case TypeTime:
ret.baseType = "string"
ret.format = "date-time"
case TypeFloat:
ret.baseType = "number"
ret.format = "float"
default:
log.L().Warn("error parsing field type", "type", t)
ret.format = "unknown"

View file

@ -3158,14 +3158,14 @@ func (b *SystemBackend) pathRandomWrite(ctx context.Context, req *logical.Reques
}
if bytes > maxBytes {
return logical.ErrorResponse(`"bytes" should be less than %s`, maxBytes), nil
return logical.ErrorResponse(`"bytes" should be less than %d`, maxBytes), nil
}
switch format {
case "hex":
case "base64":
default:
return logical.ErrorResponse(fmt.Sprintf("unsupported encoding format %s; must be \"hex\" or \"base64\"", format)), nil
return logical.ErrorResponse("unsupported encoding format %q; must be \"hex\" or \"base64\"", format), nil
}
randBytes, err := uuid.GenerateRandomBytes(bytes)