Skip to content

Commit

Permalink
bug #2600 [Autocomplete] Rethrow BadRequestHttpException in case of…
Browse files Browse the repository at this point in the history
… malformed `extra_options` (norkunas)

This PR was merged into the 2.x branch.

Discussion
----------

[Autocomplete] Rethrow `BadRequestHttpException` in case of malformed `extra_options`

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Issues        | N/A
| License       | MIT

Currently it's enough just to manually edit extra_options in URL to a random string and then get a 500 error while polluting logs. I think it's better to swallow it and properly exit with 400 status.

Commits
-------

e59554a [Autocomplete] Rethrow `BadRequestHttpException` in case of malformed `extra_options`
  • Loading branch information
Kocal committed Feb 28, 2025
2 parents 65458d6 + e59554a commit 84fcc3f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ private function getExtraOptions(Request $request): array
return [];
}

$extraOptions = $this->getDecodedExtraOptions($request->query->getString(self::EXTRA_OPTIONS));
try {
$extraOptions = $this->getDecodedExtraOptions($request->query->getString(self::EXTRA_OPTIONS));
} catch (\JsonException $e) {
throw new BadRequestHttpException('The extra options cannot be parsed.', $e);
}

if (!\array_key_exists(AutocompleteChoiceTypeExtension::CHECKSUM_KEY, $extraOptions)) {
throw new BadRequestHttpException('The extra options are missing the checksum.');
Expand Down

0 comments on commit 84fcc3f

Please sign in to comment.