extensions-sdk icon indicating copy to clipboard operation
extensions-sdk copied to clipboard

`ddClient.docker.cli.exec` result seems not to have `code` ever

Open jnummelin opened this issue 3 years ago • 1 comments

Consider this example invocation of ddClient.docker.cli.exec:

const r = await ddClient.docker.cli.exec("info", [])
r.code // r.code is always undefined

I can see the code field marked as Optional, but all the execs I've tried have not had it populated.

Is it actually populated ever?

Currently the only somewhat sane way to check exec success is to look at result.stderr being empty. Which is always bit sketchy.

jnummelin avatar Apr 08 '22 02:04 jnummelin

Hello, Thx for the feedback.

We do actually send the exit code only in case of failures, we should also send it (value '0') when everything is OK. If you change the command to include a typo, in order to make it fail, you should see the exit code along with the error message in stderr. Screenshot 2022-04-11 at 13 35 46

For now you should be able to rely on code exists and not equal to zero, we'll add it with value zero when the execution is successful in a next relase.

gtardif avatar Apr 11 '22 11:04 gtardif