Skip to content

occ output not quiet when it should be, exit code not proper #27029

Open

Description

@tgoeg

Steps to reproduce

  1. occ files:scan -- nonexistantuser
{"reqId":"gF4yvg4t66k03R7DWvY4","level":1,"time":"2021-05-19T09:45:18+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan -- nonexistant","userAgent":"--","version":"19.0.8.1"}
Unknown user 1 nonexistant
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+
$ echo $?
0
  1. occ files:scan -q -- nonexistantuser
{"reqId":"cP30drfWr696XfVOnNs1","level":1,"time":"2021-05-19T09:47:12+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan -q -- nonexistantuser","userAgent":"--","version":"19.0.8.1"}
  1. occ files:scan -q -- existinguser
{"reqId":"cP30drfWr696XfVOnNs1","level":1,"time":"2021-05-19T09:47:12+00:00","remoteAddr":"","user":"--","app":"admin_audit","method":"","url":"--","message":"Console command executed: files:scan -q -- existinguser","userAgent":"--","version":"19.0.8.1"}

Expected behaviour

  1. Less output (see 3. below), but most of all, an exit code indicating an error has occurred.
  2. I said quiet! Still I get (irrelevant, to me) output but the one that should actually be issued (there has been an error!) gets suppressed!
  3. The logfile details in JSON should generally not be shown. Silence is golden. Using this (and most likely other occ commands as well, this is a more general issue!) in cron jobs/scripts always leads to notifications. If there is no error, do not output anything. Especially not when asked to be quiet. There are verbose flags. If using them, output can be generated. Only output error messages to stderr (or maybe verbose messages, if asked to). Yes, I can redirect stderr to /dev/null but that's not sensible. I'd like to get notified if an actual error occurs!

Server configuration

Nextcloud version:
19.0.8.1

The rest is irrelevant.

Activity

  1. added
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on May 19, 2021
  2. tgoeg commented on May 19, 2021

    @tgoeg
    Author

    This is somewhat related to #24300 as this also affects scriptability.

  3. tgoeg commented on May 19, 2021

    @tgoeg
    Author

    Also related to #23596 as this is another case of not correctly separating stdout from stderr.

  4. changed the title [-]occ output not quiet when it should be, exit code not proper[/-] [+]`occ` output not quiet when it should be, exit code not proper[/+] on May 20, 2021
  5. solracsf commented on May 28, 2021

    @solracsf
    Member

    I've tested 2 and 3, no output in both cases.
    For 1, i don't get any JSON return.

    php occ files:scan -- user
    Starting scan for user 1 out of 1 (user)
    +---------+-------+--------------+
    | Folders | Files | Elapsed time |
    +---------+-------+--------------+
    | 11      | 25    | 00:00:00     |
    +---------+-------+--------------+
    

    Nextcloud 21.0.2.

  6. tgoeg commented on May 31, 2021

    @tgoeg
    Author

    Alright, reading my output again this might be caused by "app":"admin_audit"
    Still, occ should have control over what gets sent to the console and what not, right?

  7. szaimen commented on Jul 6, 2021

    @szaimen
  8. ghost added
    staleTicket or PR with no recent activity
    on Aug 5, 2021
  9. tgoeg commented on Aug 11, 2021

    @tgoeg
    Author

    Sorry for the delay - had to update OS to be able to update NC as well.
    Yes, I can confirm it is the same on NC 21.0.3, still wrong Unknown user 1 nonexistantuser output and still wrong return code.
    I don't seem to get the admin_audit stanzas anymore, regardless of using -q or not.

  10. ghost removed
    staleTicket or PR with no recent activity
    on Aug 11, 2021
  11. 6 remaining items

  12. uusijani commented on Jan 25, 2023

    @uusijani

    The exit code issue is still there:

    # sudo -u www-data /usr/bin/php /var/www/nextcloud/occ --version
    Nextcloud 25.0.3
    # sudo -u www-data /usr/bin/php /var/www/nextcloud/occ files:scan -- nonexistantuser
    Unknown user 1 nonexistantuser
    +---------+-------+--------------+
    | Folders | Files | Elapsed time |
    +---------+-------+--------------+
    | 0       | 0     | 00:00:00     |
    +---------+-------+--------------+
    # echo $?
    0
    
  13. szaimen commented on Jan 25, 2023

    @szaimen
  14. uusijani commented on Jan 25, 2023

    @uusijani
  15. sblondon commented on Jun 19, 2023

    @sblondon
  16. added
    good first issueSmall tasks with clear documentation about how and in which place you need to fix things in.
    on Nov 3, 2023
  17. added a commit that references this issue on Nov 20, 2024
    7af8f12
  18. added and removed
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

25-feedback3. to reviewWaiting for reviewsbugfeature: occgood first issueSmall tasks with clear documentation about how and in which place you need to fix things in.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions