Skip to content

Commit f2cbf64

Browse files
Be more specific with HTTP error code (422) when you pass a wrong value for a config.
400 conflicted with general errors.
1 parent d4f8c86 commit f2cbf64

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

webapp/src/Controller/API/GeneralInfoController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public function getDatabaseConfigurationAction(
249249
content: new OA\JsonContent(type: 'object')
250250
)]
251251
#[OA\Response(
252-
response: 400,
252+
response: 422,
253253
description: 'An error occurred while saving the configuration',
254254
content: new OA\JsonContent(
255255
properties: [
@@ -271,7 +271,7 @@ public function updateConfigurationAction(Request $request): JsonResponse|array
271271
{
272272
$errors = $this->config->saveChanges($request->request->all(), $this->eventLogService, $this->dj);
273273
if (!empty($errors)) {
274-
return new JsonResponse(['errors' => $errors], 400);
274+
return new JsonResponse(['errors' => $errors], Response::HTTP_UNPROCESSABLE_ENTITY);
275275
}
276276
return $this->config->all(false);
277277
}

webapp/tests/Unit/Controller/API/ConfigControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testConfigChangeAPIInvalid(
118118
static::assertEquals($currentValue, $response[$property]);
119119

120120
$proposedChange = [$property => $newValue];
121-
$response = $this->verifyApiJsonResponse('PUT', $this->endpoint, 400, 'admin', $proposedChange);
121+
$response = $this->verifyApiJsonResponse('PUT', $this->endpoint, 422, 'admin', $proposedChange);
122122

123123
static::assertEquals(['errors' => [$property => $errorMessage]], $response);
124124
}

0 commit comments

Comments
 (0)