From 68a68c2a7320f2874b0a342c9891b93f55bbf14a Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Wed, 21 Oct 2026 09:24:23 +0200 Subject: [PATCH] #66 - RequestTask: meaningful log message for a failed call, minor cleanups, document the shared client state RequestTask logs a failed call as "Soap call failed" instead of the misleading "Empty resultset for query". Remove the monolog.logger tag of RequestTransformer, which has no logger. Type MissingClientException::create(string $code). Document that a shared client keeps its state between two executions in a long-running worker. Tests, documentation and CHANGELOG updated. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 1 + config/services/transformer.yaml | 1 - docs/cookbooks/soap_enrich_csv.md | 2 +- docs/reference/client.md | 6 ++++++ docs/reference/tasks/request_task.md | 2 +- src/Exception/MissingClientException.php | 5 +---- src/Task/RequestTask.php | 2 +- .../CleverAgeSoapProcessExtensionTest.php | 3 ++- tests/Task/RequestTaskTest.php | 2 +- 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e291668..1589932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Latest ------ ### Changes +* [#66](https://github.com/cleverage/soap-process-bundle/issues/66) RequestTask logs a failed call as `Soap call failed` instead of the misleading `Empty resultset for query` (same level and log context). Remove the `monolog.logger` tag of `RequestTransformer`, which has no logger. Type `MissingClientException::create(string $code)`. Document that a client, shared, keeps its state between two process executions in a long-running worker. Update documentation and tests. * [#64](https://github.com/cleverage/soap-process-bundle/issues/64) Configuring a key under `clever_age_soap_process` is deprecated: the bundle has no configuration and the keys were ignored without notice (new internal `Configuration`, empty; notice when the container is compiled). They will be rejected in 4.0. Require `symfony/deprecation-contracts`, used directly. Update documentation, add tests. * [#62](https://github.com/cleverage/soap-process-bundle/issues/62) The bundle throws exceptions implementing `ProcessExceptionInterface` of the process bundle instead of raw SPL exceptions (as [cleverage/process-bundle#317](https://github.com/cleverage/process-bundle/issues/317)): new `Exception\UnexpectedValueException`, `Exception\InvalidArgumentException` and `Exception\RuntimeException`, extending the SPL exceptions thrown before (same messages, the existing `catch` keep working). Add tests. * [#60](https://github.com/cleverage/soap-process-bundle/issues/60) Composer: require PHP `^8.2` instead of `>=8.2` (PHP 9 is no longer accepted before being tested), remove the authorization of the `symfony/flex` plugin, which is not required (the CI installs it globally), as [cleverage/process-bundle#319](https://github.com/cleverage/process-bundle/issues/319). diff --git a/config/services/transformer.yaml b/config/services/transformer.yaml index 1cdaa8b..6fba490 100644 --- a/config/services/transformer.yaml +++ b/config/services/transformer.yaml @@ -11,7 +11,6 @@ services: tags: # The code is the one returned by RequestTransformer::getCode(): the transformer is loaded lazily - { name: cleverage.transformer, code: soap_request } - - { name: monolog.logger, channel: cleverage_process_transformer } cleverage_soap_process.transformer.request: alias: CleverAge\SoapProcessBundle\Transformer\RequestTransformer public: false diff --git a/docs/cookbooks/soap_enrich_csv.md b/docs/cookbooks/soap_enrich_csv.md index aafa920..cb21882 100644 --- a/docs/cookbooks/soap_enrich_csv.md +++ b/docs/cookbooks/soap_enrich_csv.md @@ -100,7 +100,7 @@ How it works: [CsvWriterTask](https://github.com/cleverage/process-bundle/blob/main/docs/reference/tasks/csv_writer_task.md). Note that the error output of the RequestTask is its input (the SOAP arguments), not the CSV line: the details of the -failed call (options, last request and response) are in the log context of the `Empty resultset for query` error +failed call (options, last request and response) are in the log context of the `Soap call failed` error logged by the task. To add a single value to the line instead of replacing it, the SOAP call can also be done inside a `mapping` with the diff --git a/docs/reference/client.md b/docs/reference/client.md index 9f012f3..19b416c 100644 --- a/docs/reference/client.md +++ b/docs/reference/client.md @@ -150,3 +150,9 @@ Notes `setSoapHeaders()` (e.g. in the `calls` of the service definition) are used by every call. The [RequestTask](tasks/request_task.md) and the [RequestTransformer](transformers/request_transformer.md) set their own `soap_call_options` / `soap_call_headers` for their call only, then restore these values. +* Being shared, a client keeps its state from one process execution to the next as long as the PHP process runs, e.g. + in a long-running worker (Messenger, [ui-process-bundle](https://github.com/cleverage/ui-process-bundle)): the + `SoapClient` (and so the WSDL, loaded once: `setWsdl()` has no effect after the first call), the options and headers + changed with `setSoapOptions()` / `setSoapHeaders()` and the last request and response traces (overwritten by each + call). The client is not reset between two executions: give the values specific to a call with the + `soap_call_options` / `soap_call_headers` options of the task or the transformer rather than by changing the client. diff --git a/docs/reference/tasks/request_task.md b/docs/reference/tasks/request_task.md index 0b0cbe5..fe5b610 100644 --- a/docs/reference/tasks/request_task.md +++ b/docs/reference/tasks/request_task.md @@ -89,7 +89,7 @@ Notes ----- * When the call fails (the client throws a `SoapFault`, see [client](../client.md)), the task logs an error - `Empty resultset for query`, with the options, the fault message and the last request and response in the log + `Soap call failed`, with the options, the fault message and the last request and response in the log context, then throws a `RuntimeException` (`Soap call '' on client '' failed`, with the `SoapFault` as previous exception), handled by the `error_strategy`: - with `error_strategy: skip`, the `outputs` tasks are skipped and the `error_outputs` tasks receive the input of diff --git a/src/Exception/MissingClientException.php b/src/Exception/MissingClientException.php index cb7ab65..eae111d 100644 --- a/src/Exception/MissingClientException.php +++ b/src/Exception/MissingClientException.php @@ -22,10 +22,7 @@ */ class MissingClientException extends \UnexpectedValueException implements ProcessExceptionInterface { - /** - * @param string $code - */ - public static function create($code): self + public static function create(string $code): self { $errorStr = "No Soap client with code : {$code}"; diff --git a/src/Task/RequestTask.php b/src/Task/RequestTask.php index c438c11..ad3ea3b 100644 --- a/src/Task/RequestTask.php +++ b/src/Task/RequestTask.php @@ -64,7 +64,7 @@ public function execute(ProcessState $state): void 'last_response_headers' => $client->getLastResponseHeaders(), ]; - $this->logger->error('Empty resultset for query', $logContext); + $this->logger->error('Soap call failed', $logContext); // The process manager applies the error strategy: the process fails with "stop", the error outputs // receive the task input with "skip" diff --git a/tests/DependencyInjection/CleverAgeSoapProcessExtensionTest.php b/tests/DependencyInjection/CleverAgeSoapProcessExtensionTest.php index c28f590..91dcf61 100644 --- a/tests/DependencyInjection/CleverAgeSoapProcessExtensionTest.php +++ b/tests/DependencyInjection/CleverAgeSoapProcessExtensionTest.php @@ -142,7 +142,8 @@ public function testTransformerIsRegistered(): void // Public for the direct access from the service container, deprecated self::assertTrue($transformer->isPublic()); self::assertSame([['package' => 'cleverage/soap-process-bundle', 'version' => '3.3']], $transformer->getTag('container.private')); - self::assertSame([['channel' => 'cleverage_process_transformer']], $transformer->getTag('monolog.logger')); + // No logger + self::assertFalse($transformer->hasTag('monolog.logger')); $arguments = $transformer->getArguments(); self::assertCount(1, $arguments); self::assertInstanceOf(Reference::class, $arguments[0]); diff --git a/tests/Task/RequestTaskTest.php b/tests/Task/RequestTaskTest.php index c64c13a..9d0e83f 100644 --- a/tests/Task/RequestTaskTest.php +++ b/tests/Task/RequestTaskTest.php @@ -118,7 +118,7 @@ public function testFailedCall(): void self::assertNull($state->getOutput()); $errors = array_values(array_filter($this->logs, static fn (array $log): bool => 'error' === $log['level'])); self::assertCount(1, $errors); - self::assertSame('Empty resultset for query', $errors[0]['message']); + self::assertSame('Soap call failed', $errors[0]['message']); self::assertSame('Unknown method', $errors[0]['context']['message']); self::assertIsString($errors[0]['context']['last_response']); self::assertStringContainsString('Unknown method', $errors[0]['context']['last_response']);