mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	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:
		| @@ -64,14 +64,14 @@ func (b *backend) pathRandomWrite(ctx context.Context, req *logical.Request, d * | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if bytes > maxBytes { | 	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 { | 	switch format { | ||||||
| 	case "hex": | 	case "hex": | ||||||
| 	case "base64": | 	case "base64": | ||||||
| 	default: | 	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) | 	randBytes, err := uuid.GenerateRandomBytes(bytes) | ||||||
|   | |||||||
| @@ -575,6 +575,9 @@ func convertType(t FieldType) schemaType { | |||||||
| 	case TypeTime: | 	case TypeTime: | ||||||
| 		ret.baseType = "string" | 		ret.baseType = "string" | ||||||
| 		ret.format = "date-time" | 		ret.format = "date-time" | ||||||
|  | 	case TypeFloat: | ||||||
|  | 		ret.baseType = "number" | ||||||
|  | 		ret.format = "float" | ||||||
| 	default: | 	default: | ||||||
| 		log.L().Warn("error parsing field type", "type", t) | 		log.L().Warn("error parsing field type", "type", t) | ||||||
| 		ret.format = "unknown" | 		ret.format = "unknown" | ||||||
|   | |||||||
| @@ -3158,14 +3158,14 @@ func (b *SystemBackend) pathRandomWrite(ctx context.Context, req *logical.Reques | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if bytes > maxBytes { | 	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 { | 	switch format { | ||||||
| 	case "hex": | 	case "hex": | ||||||
| 	case "base64": | 	case "base64": | ||||||
| 	default: | 	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) | 	randBytes, err := uuid.GenerateRandomBytes(bytes) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jim Kalafut
					Jim Kalafut