Skip to content

pods()->logs() will error if the pod's log output is in JSON format #125

Description

@i-edwards

I have a job that does some processing and sends its results to stdout in JSON format, e.g. {"name":"job","lines":222,"jobDate":"2023-11-14 07:36:29"}.

I then query Client::pods()->logs($jobPod) to retrieve the output of the job.

src/Repositories/PodRepository.php::logs() is typed to return a string (fine), but the issue is that src/Client.php::sendRequest() will automatically decode JSON into an array, which will trigger a type error when logs() tries to return it.

I'm not sure what the best way to fix this is. Maybe the easiest is to have the logs() function check if the response is an array, and re-encode it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions