Running any kbagent --json ... command whose output contains non-ASCII characters (in our case an arrow present inside a flow name) crashes on Windows instead of printing JSON.
Reproduced with:
Traceback (trimmed):
File "keboola_agent_cli/commands/flow.py", line 200, in flow_list
formatter.output(result)
File "keboola_agent_cli/output.py", line 57, in output
sys.stdout.write(response.model_dump_json(indent=2) + "\n")
File ".../encodings/cp1250.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '→' in position 28156: character maps to <undefined>
Environment: Windows 11, PowerShell/Git Bash, default console codepage cp1250 (not UTF-8).
Workaround: forcing UTF-8 before invoking the CLI avoids the crash:
PYTHONIOENCODING=utf-8 PYTHONUTF8=1 kbagent --json flow list
Why this matters: --json mode exists specifically for machine consumption (piping to a file or another program), so it shouldn't depend on the active console codepage. Any project/flow/config name containing a non-ASCII character (arrows, accented characters, emoji, etc.) makes --json unusable on a default Windows terminal.
Suggested fix: in JSON/machine-output mode, output.py should write to stdout using UTF-8 explicitly (e.g. reconfigure sys.stdout encoding, or write UTF-8 bytes directly) instead of relying on the inherited console codepage.
Running any
kbagent --json ...command whose output contains non-ASCII characters (in our case an arrow present inside a flow name) crashes on Windows instead of printing JSON.Reproduced with:
Traceback (trimmed):
Environment: Windows 11, PowerShell/Git Bash, default console codepage cp1250 (not UTF-8).
Workaround: forcing UTF-8 before invoking the CLI avoids the crash:
Why this matters:
--jsonmode exists specifically for machine consumption (piping to a file or another program), so it shouldn't depend on the active console codepage. Any project/flow/config name containing a non-ASCII character (arrows, accented characters, emoji, etc.) makes--jsonunusable on a default Windows terminal.Suggested fix: in JSON/machine-output mode,
output.pyshould write to stdout using UTF-8 explicitly (e.g. reconfiguresys.stdoutencoding, or write UTF-8 bytes directly) instead of relying on the inherited console codepage.