Page MenuHomePhabricator

[jobs-cli] broken pipe error when using `toolforge jobs logs <jobname>| head`
Closed, ResolvedPublic

Description

It should not complain, instead it should just exit, but now it shows:

local.tf-test2@toolslocal:~$ toolforge jobs logs testlogs1 | head
2026-07-28T14:52:40.996519Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:40 PM UTC 2026
2026-07-28T14:52:41.998911Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:41 PM UTC 2026
2026-07-28T14:52:43.001762Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:43 PM UTC 2026
2026-07-28T14:52:44.004284Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:44 PM UTC 2026
2026-07-28T14:52:45.007260Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:45 PM UTC 2026
2026-07-28T14:52:46.009931Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:46 PM UTC 2026
2026-07-28T14:52:47.011774Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:47 PM UTC 2026
2026-07-28T14:52:48.014193Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:48 PM UTC 2026
2026-07-28T14:52:49.017261Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:49 PM UTC 2026
2026-07-28T14:52:50.019532Z [testlogs1-c4975cf44-hgqd6] [job] Tue Jul 28 02:52:50 PM UTC 2026
ERROR: An internal error occurred while executing this command.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tjf_cli/cli.py", line 1177, in main
    run_subcommand(
    ~~~~~~~~~~~~~~^
        args=args, jobs_api=jobs_api, logs_api=logs_api, toolname=toolname
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/tjf_cli/cli.py", line 1084, in run_subcommand
    op_logs(
    ~~~~~~~^
        api=logs_api,
        ^^^^^^^^^^^^^
    ...<4 lines>...
        until=args.until,
        ^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3/dist-packages/tjf_cli/cli.py", line 812, in op_logs
    print(
    ~~~~~^
        f"{log_entry['datetime']} [{log_entry['pod']}] [{log_entry['container']}] {log_entry['message']}"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
BrokenPipeError: [Errno 32] Broken pipe
ERROR: Please report this issue to the Toolforge admins if it persists: https://w.wiki/6Zuu