nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.37k stars 4.07k forks source link

Upgrade notice should not be displayed when occ is run with --output=json #8092

Open nkakouros opened 6 years ago

nkakouros commented 6 years ago

Steps to reproduce

  1. Install an outdated version of Nextcloud or an app
  2. Run on the server php occ app:list --output=json

Expected behaviour

Everything should be output as a JSON string. Eg:

{
    "enabled": {
        "activity": "2.5.2",
        "calendar": "1.5.4",
        "comments": "1.2.0",
        "dav": "1.3.1",
        "federatedfilesharing": "1.2.0",
        "federation": "1.2.0",
        "files": "1.7.2",
        "files_pdfviewer": "1.1.1",
        "files_sharing": "1.4.0",
        "files_texteditor": "2.4.1",
        "files_trashbin": "1.2.0",
        "files_versions": "1.5.0",
        "files_videoplayer": "1.1.0",
        "firstrunwizard": "2.1",
        "gallery": "17.0.0",
        "logreader": "2.0.0",
        "lookup_server_connector": "1.0.0",
        "nextcloud_announcements": "1.1",
        "notifications": "2.0.0",
        "oauth2": "1.0.5",
        "password_policy": "1.2.2",
        "provisioning_api": "1.2.0",
        "serverinfo": "1.2.0",
        "sharebymail": "1.2.0",
        "spreedme": "0.3.11",
        "survey_client": "1.0.0",
        "systemtags": "1.2.0",
        "theming": "1.3.0",
        "twofactor_backupcodes": "1.1.1",
        "updatenotification": "1.2.0",
        "workflowengine": "1.2.0"
    },
    "disabled": {
        "admin_audit": null,
        "encryption": null,
        "files_external": null,
        "user_external": null,
        "user_ldap": null
    }
}

Actual behaviour

The notice about a required update is shown that breaks the json text. Eg:

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
{
    "enabled": {
        "activity": "2.5.2",
        "calendar": "1.5.4",
        "comments": "1.2.0",
        "dav": "1.3.1",
        "federatedfilesharing": "1.2.0",
        "federation": "1.2.0",
        "files": "1.7.2",
        "files_pdfviewer": "1.1.1",
        "files_sharing": "1.4.0",
        "files_texteditor": "2.4.1",
        "files_trashbin": "1.2.0",
        "files_versions": "1.5.0",
        "files_videoplayer": "1.1.0",
        "firstrunwizard": "2.1",
        "gallery": "17.0.0",
        "logreader": "2.0.0",
        "lookup_server_connector": "1.0.0",
        "nextcloud_announcements": "1.1",
        "notifications": "2.0.0",
        "oauth2": "1.0.5",
        "password_policy": "1.2.2",
        "provisioning_api": "1.2.0",
        "serverinfo": "1.2.0",
        "sharebymail": "1.2.0",
        "spreedme": "0.3.11",
        "survey_client": "1.0.0",
        "systemtags": "1.2.0",
        "theming": "1.3.0",
        "twofactor_backupcodes": "1.1.1",
        "updatenotification": "1.2.0",
        "workflowengine": "1.2.0"
    },
    "disabled": {
        "admin_audit": null,
        "encryption": null,
        "files_external": null,
        "user_external": null,
        "user_ldap": null
    }
}

If you try to parse the command output as json, it will fail. Perhaps, there could be an extra json key that contains the notice.

juliusknorr commented 6 years ago

Maybe we can just send the error message to stderr instead of stdin to keep it like that and have a valid json.

simonspa commented 4 years ago

As a workaround the occ command has the --no-warnings option which should do exactly this, no?