Skip to content

Commit 49e6fff

Browse files
authored
Merge pull request #4 from ovh/dev/phsym/error-request-id
feat: add request-id to error responses
2 parents 571055a + d28ec2b commit 49e6fff

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

.github/codegen/schemas/swagger.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,7 @@
12301230
"in": "query",
12311231
"description": "Continuation token from previous incomplete call",
12321232
"schema": {
1233+
"maxLength": 50,
12331234
"type": "string"
12341235
}
12351236
},
@@ -1238,7 +1239,7 @@
12381239
"in": "query",
12391240
"description": "Maximum number of keys returned in one call",
12401241
"schema": {
1241-
"maximum": 500,
1242+
"maximum": 100,
12421243
"minimum": 10,
12431244
"type": "integer",
12441245
"format": "int32",
@@ -2537,12 +2538,14 @@
25372538
"properties": {
25382539
"error_id": {
25392540
"type": "string",
2540-
"description": "Error id"
2541+
"description": "Error id",
2542+
"readOnly": true
25412543
},
25422544
"error_code": {
25432545
"type": "integer",
25442546
"description": "Error code",
2545-
"format": "int32"
2547+
"format": "int32",
2548+
"readOnly": true
25462549
},
25472550
"errors": {
25482551
"type": "array",
@@ -2551,6 +2554,11 @@
25512554
},
25522555
"description": "List with text error messages associated with ErrorId",
25532556
"readOnly": true
2557+
},
2558+
"request_id": {
2559+
"type": "string",
2560+
"description": "Request id",
2561+
"readOnly": true
25542562
}
25552563
},
25562564
"additionalProperties": false,

.github/codegen/schemas/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.14 (manually modified)
1+
0.9.16 (manually modified)

errors.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ type KmsError struct {
187187
ErrorCode ErrorCode
188188
ErrorId string
189189
Errors []error
190+
RequestId string
190191
}
191192

192193
func NewKmsErrorFromBytes(sbody []byte) *KmsError {
@@ -210,13 +211,16 @@ func newKmsErrorFromRestResponse(resp types.ErrorResponse) *KmsError {
210211
kmsErr.Errors = append(kmsErr.Errors, errors.New(er))
211212
}
212213
}
214+
if resp.RequestId != nil {
215+
kmsErr.RequestId = *resp.RequestId
216+
}
213217
return kmsErr
214218
}
215219

216220
func (err *KmsError) Error() string {
217221
errs := make([]error, 0, len(err.Errors)+1)
218222
errs = append(errs, err.Errors...)
219-
errs = append(errs, fmt.Errorf("ID=%s, %s", err.ErrorId, err.ErrorCode))
223+
errs = append(errs, fmt.Errorf("ID=%q, Request-ID:%q, %s", err.ErrorId, err.RequestId, err.ErrorCode))
220224
return errors.Join(errs...).Error()
221225
}
222226

types/types.gen.go

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)