borgmatic --json info outputs non-json warnings #602

Closed
opened 2022-10-21 13:57:42 +00:00 by satwell · 3 comments
Contributor

What I'm trying to do and why

Parse the output of borgmatic --json info in other scripts.

Steps to reproduce (if a bug)

Run borgmatic --json info 2>/dev/null with repositories configured to use deprecated SSH location syntax like user@host:backups.

Actual behavior (if a bug)

The above borgmatic command (which discards stderr output) will output something like this:

[{ ...json... }]
summary:
/etc/borgmatic/config.yaml: Remote repository paths without ssh:// syntax are deprecated. Interpreting "user@host:backups" as "ssh://user@host/./backups"

Expected behavior (if a bug)

Whne using --json, only parse-able JSON should go to stdout. Other messages should go to stderr. Otherwise, tools that parse the output will break.

Other notes / implementation ideas

Environment

borgmatic version: 1.7.4

borgmatic installation method: pex

Borg version: 1.1.16

Python version: 3.9.2

operating system and version: Debian Bullseye

#### What I'm trying to do and why Parse the output of `borgmatic --json info` in other scripts. #### Steps to reproduce (if a bug) Run `borgmatic --json info 2>/dev/null` with repositories configured to use deprecated SSH location syntax like `user@host:backups`. #### Actual behavior (if a bug) The above `borgmatic` command (which discards stderr output) will output something like this: ``` [{ ...json... }] summary: /etc/borgmatic/config.yaml: Remote repository paths without ssh:// syntax are deprecated. Interpreting "user@host:backups" as "ssh://user@host/./backups" ``` #### Expected behavior (if a bug) Whne using `--json`, only parse-able JSON should go to stdout. Other messages should go to stderr. Otherwise, tools that parse the output will break. #### Other notes / implementation ideas #### Environment **borgmatic version:** 1.7.4 **borgmatic installation method:** pex **Borg version:** 1.1.16 **Python version:** 3.9.2 **operating system and version:** Debian Bullseye
Owner

Good find, and thank you for filing this!

Good find, and thank you for filing this!
witten added the
bug
label 2022-10-21 16:50:09 +00:00
Owner

This is fixed in master and will be part of the next release. Warnings now go to stderr instead of stdout. In order to make this possible, I had to stop abusing the warning level and make certain logs (such as the output of borgmatic list) go to a new custom log level so they'd still show up on stdout.

Thanks again for filing this!

This is fixed in master and will be part of the next release. Warnings now go to stderr instead of stdout. In order to make this possible, I had to stop abusing the warning level and make certain logs (such as the output of `borgmatic list`) go to a new custom log level so they'd still show up on stdout. Thanks again for filing this!
Owner

Just released in borgmatic 1.7.6!

Just released in borgmatic 1.7.6!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#602
No description provided.