Skip to content

occ --output=json prints invalid json when an upgrade is needed #23596

Closed

Description

@kyrofa

Typical usage of occ --output=json takes the output and immediately consumes it with something that expects json (e.g. jq if you're writing bash scripts). However, if Nextcloud needs an upgrade, for example, occ also prints a (text) warning before printing out the json. For example:

$ sudo -u www-data php occ status --output=json
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
{"installed":true,"version":"19.0.4.2","versionstring":"19.0.4","edition":""}

Note the "Nextcloud or one of the apps require upgrade" text. That makes the output invalid json. This is hard to deal with properly-- they're both going to stdout, and thus can't be separated. If the user is explicitly requesting the output be json, it would be very nice to stick to that request. Either don't print warnings/errors in that situation, or make those fit into the json response somehow, perhaps by adding an "errors" item to the response.

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