Skip to content

Commit

Permalink
Be more specific with HTTP error code (422) when you pass a wrong val…
Browse files Browse the repository at this point in the history
…ue for a config.

400 conflicted with general errors.
  • Loading branch information
Nicky Gerritsen committed Jan 12, 2024
1 parent d4f8c86 commit dc42761
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions webapp/src/Controller/API/GeneralInfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function getDatabaseConfigurationAction(
content: new OA\JsonContent(type: 'object')
)]
#[OA\Response(
response: 400,
response: 422,
description: 'An error occurred while saving the configuration',
content: new OA\JsonContent(
properties: [
Expand All @@ -271,7 +271,7 @@ public function updateConfigurationAction(Request $request): JsonResponse|array
{
$errors = $this->config->saveChanges($request->request->all(), $this->eventLogService, $this->dj);
if (!empty($errors)) {
return new JsonResponse(['errors' => $errors], 400);
return new JsonResponse(['errors' => $errors], Response::HTTP_UNPROCESSABLE_ENTITY);
}
return $this->config->all(false);
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/tests/Unit/Controller/API/ConfigControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function testConfigChangeAPIInvalid(
static::assertEquals($currentValue, $response[$property]);

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

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

0 comments on commit dc42761

Please sign in to comment.