Skip to content

cleverage:process:execute: invalid UTF-8 in the json-stream output file throws a JsonException #455

Closed

Description

@njoubert-cleverage

Description

Since #226, cleverage:process:execute --output-format=json-stream replaces the invalid UTF-8 sequences of the output written to STDOUT. But with --output <file>, the output is written by JsonStreamFile with JSON_THROW_ON_ERROR only: an output with invalid UTF-8 (e.g. a value read from a Latin-1 file) throws a JsonException and the command fails.

The same path writes the JSON buffer of the process_launcher task (json_buffering): the sub-process fails.

Reproduction

A process whose end point outputs ['name' => "Caf\xe9"]:

$ bin/console cleverage:process:execute my.process -o var/out.json-stream -t json-stream

Actual: JsonException: Malformed UTF-8 characters, possibly incorrectly encoded.

Expected: {"name":"Caf�"} in the file, as on STDOUT.

Tested on v5.8, PHP 8.5.

Proposed fix

JSON_INVALID_UTF8_SUBSTITUTE for the output file too; an output that still cannot be encoded (e.g. NAN) is reported on the error output, as on STDOUT.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None.

Activity

  1. added 2 commits that reference this issue on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions