globus / globus-cli

A command line interface to Globus
https://docs.globus.org/cli
Apache License 2.0
74 stars 21 forks source link

Fix handling of API errors with null JSON data #983

Closed sirosen closed 6 months ago

sirosen commented 6 months ago
  1. Before the JSON printing hook, add a generic hook for any data with a null body.

This lets the JSON printing hook stay small and single-purpose, but avoids passing a null bodied error to any subsequent hook.

  1. Fix a dropped assignment in write_error_info() when the output is JSON.

This was broken at some point in the past, but is basically unreachable when a normal error occurs, now that we have a dedicated JSON-printing hook as one of the first hooks.

It needs to either be fixed or removed, and for the immediate change it is fixed and used by the null data printer.

A couple of test cases are included for the GlobusAPINullDataError case, which should be easy to identify if it occurs in the wild in the future.