Fixed issues

Fixed issues

Bugs from previous versions and the version in which they were fixed. If you are on an affected version, upgrade or use the workaround. Open issues are on the Open issues page.

REST calls did not fire rpc.post_response

Fixed in 1.3 (not released yet)

Affected versions: 1.0.0 — 1.2.0. According to the 1.3 release notes.

Symptom. After a REST call rpc.post_response listeners did not run: #[RPC\CacheRelation] invalidation, async and post-response listeners of the application.

Fix. The controller executes the request through the JsonRpcBundle 10.4.2 RpcExecutor; a successful call gets rpc.post_response on kernel.terminate.


Path and query values did not fit typed parameters

Fixed in 1.3 (not released yet)

Affected versions: 1.0.0 — 1.2.0.

Symptom. GET /rest/catalog/items/42 for item(int $id) returned 400 with must be of type int, string given.

Fix. RpcFromRest casts strings from the path, query and form to the declared scalar type of the parameter; see Request parameters.


Unknown method and constraint errors returned 400

Fixed in 1.3 (not released yet)

Affected versions: 1.0.0 — 1.2.0.

Symptom. RpcMethodNotFoundExceptionRpc and ConstraintsImposedException were returned as 400 instead of 404 and 422.

Cause. Both classes are subclasses of RpcBadRequestException, which came before them in RestErrorNormalizer::ERROR_MAPPING; in addition, RestValidationException did not implement RestErrorInterface and could not be created without an array of constraints.

Fix. Subclasses are checked before their parent classes; RestValidationException implements RestErrorInterface and takes the constraints from the previous exception.


The HTTP code of an application error was ignored

Fixed in 1.3 (not released yet)

Affected versions: 1.0.0 — 1.2.0.

Symptom. throw new CustomApplicationException('Order is closed', 409) from a method returned 400.

Cause. RestErrorNormalizer created the REST exception with code 0 for the classes from the table, and for the rest checked the code with in_array() against the status texts, so the check never matched.

Fix. The HTTP error code of the exception is kept; see Error handling.


RestApplicationException did not load

Fixed in 1.3 (not released yet)

Affected versions: 1.0.0 — 1.2.0.

Symptom. A fatal error when using RestApplicationException or converting an application error.

Cause. The class extended Ufo\RpcError\RpcCustomApplicationException, which does not exist in ufo-tech/rpc-exceptions 2.x.

Fix. The class extends Ufo\RpcError\CustomApplicationException; the constructor arguments are optional.


The Postman collection failed with JsonRpcBundle 10.3+

Fixed in 1.3 (not released yet)

Affected versions: 1.2.0. According to the 1.3 release notes.

Symptom. GET /rest/postman ended with a fatal error with JsonRpcBundle 10.3 and later.

Cause. PostmanAdapter redeclared the $requestStack property, which the base AbstractPostmanAdapter received in 10.3.

Fix. RequestStack is passed to the base adapter constructor.


An invalid JSON body was ignored

Fixed in 1.1.0

Affected versions: 1.0.0.

Symptom. The method was executed without body parameters if the body was not valid JSON.

Fix. An invalid or scalar JSON body returns 400.


A wrong HTTP method returned 404

Fixed in 1.1.0

Affected versions: 1.0.0.

Symptom. A request to an existing path with an HTTP method missing from #[Route] returned 404.

Fix. Each REST route gets a <name>_method_not_allowed fallback route, and such a request returns 405.