You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: improved validation and error responses (#719)
* pr 1: improve validation
Signed-off-by: Mathew Wicks <[email protected]>
Signed-off-by: Andy Stoneberg <[email protected]>
* chore: improved validation and error responses
- Updated StatusCausesFromAPIStatus to also return causes from StatusReasonConflict
- Enhanced PauseActionWorkspaceHandler and CreateWorkspaceHandler to utilize IsEOFError for better error responses.
- Enhanced PauseActionWorkspaceHandler to ensure conflict_causes[] is present when Patch operation returns Invalid
- Introduced new test files for response error handling and validation helper functions.
Signed-off-by: Andy Stoneberg <[email protected]>
---------
Signed-off-by: Andy Stoneberg <[email protected]>
Co-authored-by: Mathew Wicks <[email protected]>
Copy file name to clipboardExpand all lines: workspaces/backend/api/response_errors.go
+80-8Lines changed: 80 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ const (
29
29
errMsgPathParamsInvalid="path parameters were invalid"
30
30
errMsgRequestBodyInvalid="request body was invalid"
31
31
errMsgKubernetesValidation="kubernetes validation error (note: .cause.validation_errors[] correspond to the internal k8s object, not the request body)"
32
+
errMsgKubernetesConflict="kubernetes conflict error (see .cause.conflict_cause[] for details)"
32
33
)
33
34
34
35
// ErrorEnvelope is the body of all error responses.
@@ -42,19 +43,66 @@ type HTTPError struct {
42
43
}
43
44
44
45
typeErrorResponsestruct {
45
-
Codestring`json:"code"`
46
-
Messagestring`json:"message"`
47
-
Cause*ErrorCause`json:"cause,omitempty"`
46
+
// Code is a string representation of the HTTP status code.
47
+
Codestring`json:"code"`
48
+
49
+
// Message is a human-readable description of the error.
50
+
Messagestring`json:"message"`
51
+
52
+
// Cause contains detailed information about the cause of the error.
53
+
Cause*ErrorCause`json:"cause,omitempty"`
48
54
}
49
55
50
56
typeErrorCausestruct {
57
+
// ConflictCauses contains details about conflict errors that caused the request to fail.
0 commit comments