-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
Wrong HTTP status for the Unprocessable Entity mapping
Line 140 builds a .httpErrorWithDetails using status code 421 while sourcing data from Components.Responses.UnprocessableEntity, whose actual HTTP status is 422. This mislabels the error and propagates the wrong status everywhere the initializer is used. Please align the initializer name and status code with 422.
- /// Initialize CloudKitError from an UnprocessableEntity response (misdirected request)
- internal init(misdirectedRequest response: Components.Responses.UnprocessableEntity) {
+ /// Initialize CloudKitError from an UnprocessableEntity response
+ internal init(unprocessableEntity response: Components.Responses.UnprocessableEntity) {
if case .json(let errorResponse) = response.body {
self = .httpErrorWithDetails(
- statusCode: 421,
+ statusCode: 422,
serverErrorCode: errorResponse.serverErrorCode?.rawValue,
reason: errorResponse.reason
)
} else {
- self = .httpError(statusCode: 421)
+ self = .httpError(statusCode: 422)
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
/// Initialize CloudKitError from an UnprocessableEntity response
internal init(unprocessableEntity response: Components.Responses.UnprocessableEntity) {
if case .json(let errorResponse) = response.body {
self = .httpErrorWithDetails(
statusCode: 422,
serverErrorCode: errorResponse.serverErrorCode?.rawValue,
reason: errorResponse.reason
)
} else {
self = .httpError(statusCode: 422)
}
}
🤖 Prompt for AI Agents
In Sources/MistKit/Service/CloudKitError+OpenAPI.swift around lines 135 to 145,
the initializer for "misdirectedRequest" incorrectly uses HTTP status 421 when
mapping from Components.Responses.UnprocessableEntity (which is 422); change the
status code to 422 and update any descriptive names or comments to match
"Unprocessable Entity" so the initializer builds
.httpErrorWithDetails(statusCode: 422, ...) (and .httpError(statusCode: 422) in
the non-JSON branch).
Originally posted by @coderabbitai[bot] in #105 (comment)
Metadata
Metadata
Assignees
Labels
No labels