You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI: give project logs a longer timeout and report a timeout accurately (#1231) - #153
th-cli project logs failed after 5.8 s with ReadTimeout on a project with 12 executions (36 MB of logs), although the backend was running and served the same download correctly. The command used httpx's default 5 s read timeout, and the backend builds the whole archive before it sends the first byte, so the wait grows with the project.
Changes
th_cli/commands/project.py
New PROJECT_LOGS_TIMEOUT (300 s read, 10 s connect), passed to get_client() through a new optional timeout argument of get_sync_apis(). Only project logs uses it; every other project command keeps the default.
A ReadTimeout while downloading is now reported as "Timed out waiting for the logs of project N: no data received for 300s. The backend accepted the connection; building the archive of a project with many or large executions can take longer than that." The previous text ("Is the backend running? Try th-cli doctor") was wrong for this case: a read timeout means the connection was made. The wording is phase-neutral on purpose: httpx's read timeout applies between chunks, so it does not say whether the first byte ever arrived. Other transport errors, including connect, write and pool timeouts, keep the generic handler and the backend hint, and no partial file is written.
tests/test_project_commands.py: new TestProjectLogsTimeout (5 tests): the extended timeout is requested, other commands keep the default, a read timeout gives the new message without the backend hint and writes no file, a refused connection keeps the hint, and connect, write and pool timeouts are not reported as a slow archive.
The 300 s is a judgement call. A single execution's log download gets 120 s (TEST_RUN_EXECUTION_IO_TIMEOUT) and a project is the sum of its executions. It is a constant, easy to adjust once there are timings from larger projects.
Not in this PR
The backend still builds the whole archive before it responds and stores it uncompressed (36.1 MB compressed and uncompressed in the case above). Streaming the archive while it is built, and compressing it, would remove the dependency on a timeout altogether; that is a separate backend change.
Testing
tests/test_project_commands.py: 71 passed (66 before, plus the 5 new tests).
Whole CLI suite: the same 47 tests fail on v2.17-cli-develop without this change and with it (all in other test files, such as test_run_tests.py and test_tc_params_mapping.py, which do not touch this code); 5 more pass with it, the new ones. I did not investigate those 47.
isort and flake8 are clean for the changed files; black leaves th_cli/commands/project.py unchanged.
On the TH host where it failed, th-cli project logs on the project with 12 executions no longer times out.
th-cli project logs failed after 5.8s with ReadTimeout on a project with 12 executions (36 MB of logs): the
command used httpx's default 5s read timeout, but the backend builds the whole archive before it sends the
first byte, so the wait grows with the project. Other long-running commands already set their own timeout.
- PROJECT_LOGS_TIMEOUT (300s read, 10s connect) for project logs only, passed through get_sync_apis(timeout=).
- A timeout is no longer reported as 'Is the backend running?': the connection worked, the backend is just still
building the archive. Other transport errors keep the backend hint.
Refs project-chip/certification-tool#1232
The project logs command now uses a dedicated client timeout of 300 seconds for reads and writes, and 10 seconds for connections. Other project commands retain the default timeout. When a log download fails because of a timeout, the CLI reports that the backend is reachable but has not started sending the archive. Other transport errors retain their existing handling.
The longer log-download timeout works as intended, but some timeout errors will give a misleading explanation of what went wrong. This is a small diagnostic issue and is worth fixing before merge.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
[#1231] Verified at head in th_cli/commands/project.py: PROJECT_LOGS_TIMEOUT = Timeout(300.0, connect=10.0) is defined; get_sync_apis(operation, timeout=None) forwards the timeout to get_client(timeou…
Provide a readable view of _download_project_logs in th_cli/commands/project.py at head (or a diff of that hunk) to confirm that a TimeoutException wrapped in ResponseHandlingException raises the reachable-but-slow CLIError without the back…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title names the two changes in this PR: a longer timeout for project logs and accurate reporting of timeouts. The raw summary confirms both: PROJECT_LOGS_TIMEOUT is added, and a timeout raises…
Out of Scope Changes check
The changes visible at head fall within the scope of [#1231]. The timeout constant and its forwarding through get_sync_apis() affect only the project logs command. The project logs error message chang…
Description check
The description states the problem (ReadTimeout on th-cli project logs with 12 executions), the changes to th_cli/commands/project.py (PROJECT_LOGS_TIMEOUT, optional timeout argument of get_sync_apis,…
Full details: Title check
Explanation
The title names the two changes in this PR: a longer timeout for project logs and accurate reporting of timeouts. The raw summary confirms both: PROJECT_LOGS_TIMEOUT is added, and a timeout raises a specific CLIError message. The title is specific and matches the main change.
Full details: Out of Scope Changes check
Explanation
The changes visible at head fall within the scope of [#1231]. The timeout constant and its forwarding through get_sync_apis() affect only the project logs command. The project logs error message change is the requested fix. The PR summary and the AI-generated summary report no change to backend code, and the visible changed files are th_cli/commands/project.py and tests/test_project_commands.py. The issue excludes backend archive changes, and none are reported. The unread part of _download_project_logs is not assessed here; its scope is covered by the linked-issue assessment.
Full details: Description check
Explanation
The description states the problem (ReadTimeout on th-cli project logs with 12 executions), the changes to th_cli/commands/project.py (PROJECT_LOGS_TIMEOUT, optional timeout argument of get_sync_apis, revised read-timeout message), the new TestProjectLogsTimeout tests, and the testing performed. It is specific and clearly related to the changeset, so it passes.
Full details: Linked Issues check
Explanation
[#1231] Verified at head in th_cli/commands/project.py: PROJECT_LOGS_TIMEOUT = Timeout(300.0, connect=10.0) is defined; get_sync_apis(operation, timeout=None) forwards the timeout to get_client(timeout=...); the logs command passes PROJECT_LOGS_TIMEOUT; other commands call get_sync_apis without a timeout and keep the default. th_cli/client.py at head already accepts timeout in get_client(), so the forwarding is valid. Not verified: the body of _download_project_logs, which the file read truncated. The acceptance criterion that a read timeout reports a reachable-but-slow backend and that a refused connection keeps the backend hint depends on that function. The PR summary and the AI-generated summary describe this behavior, and the 5 new tests reportedly cover it, but neither is source evidence. The diff tool returned no output for th_cli/commands/project.py and tests/test_project_commands.py, so the test file was not read. Timeout extension and default preservation are supported. The message behavior is unconfirmed.
Resolution
Provide a readable view of _download_project_logs in th_cli/commands/project.py at head (or a diff of that hunk) to confirm that a TimeoutException wrapped in ResponseHandlingException raises the reachable-but-slow CLIError without the backend hint, that other transport errors keep the hint, and that no partial file is written. Provide the TestProjectLogsTimeout tests in tests/test_project_commands.py to confirm they assert these behaviors.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
rquidute
changed the title
CLI: give project logs a longer timeout and report a timeout accurately (#1232)
CLI: give project logs a longer timeout and report a timeout accurately (#1231)
Dec 3, 2026
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 345579bd-92fd-4805-9d9c-ff713b201f50
Commits
Reviewing files that changed from the base of the PR and between 034130a and 0b3102e.
Files selected for processing: 2
tests/test_project_commands.py
th_cli/commands/project.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Do not classify connection timeouts as slow archive generation.
If connection establishment times out after 10 seconds, ConnectTimeout passes this guard because it inherits TimeoutException. The command then claims that the backend is reachable and that it waited 300 seconds. HTTPX does not establish either fact in this case. (raw.githubusercontent.com)
Restrict this branch to ReadTimeout. Let other timeout types reach the existing transport-error handler. Update the test that requires the archive-start message for WriteTimeout and PoolTimeout; those failures also do not establish archive generation. (raw.githubusercontent.com)
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Do not infer that transmission never started from a read timeout.
If the backend sends part of the archive and then stops sending for 300 seconds, HTTPX raises ReadTimeout while buffering the remaining body. Its read timeout applies between chunks, not only before the first byte. This message incorrectly attributes that failure to archive generation. Restricting the exception type does not fix this case. (raw.githubusercontent.com)
Use phase-neutral wording, such as “Timed out waiting for project logs data after 300 seconds without receiving data.” Describe archive generation as a possible cause, not an established fact.
Both points addressed in 72baf82 (87a25de plus a line-wrap fix). The handler now catches only ReadTimeout; connect, write and pool timeouts reach the generic transport-error handler. The message no longer claims the first byte never arrived: "Timed out waiting for the logs of project N: no data received for 300s. The backend accepted the connection; building the archive ... can take longer than that." The test that required the archive message for write and pool timeouts now asserts the opposite, and a ConnectTimeout case is added.
Closing this. @greens was right: the failure came from a backend without the streaming change..
I re-tested on a clean install of v2.16+winter2026, whose backend includes #419, with the CLI exactly as pinned there (default timeouts, none of this PR's changes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1231
th-cli project logsfailed after 5.8 s withReadTimeouton a project with 12 executions (36 MB of logs), although the backend was running and served the same download correctly. The command used httpx's default 5 s read timeout, and the backend builds the whole archive before it sends the first byte, so the wait grows with the project.Changes
th_cli/commands/project.pyPROJECT_LOGS_TIMEOUT(300 s read, 10 s connect), passed toget_client()through a new optionaltimeoutargument ofget_sync_apis(). Onlyproject logsuses it; every otherprojectcommand keeps the default.ReadTimeoutwhile downloading is now reported as "Timed out waiting for the logs of project N: no data received for 300s. The backend accepted the connection; building the archive of a project with many or large executions can take longer than that." The previous text ("Is the backend running? Tryth-cli doctor") was wrong for this case: a read timeout means the connection was made. The wording is phase-neutral on purpose: httpx's read timeout applies between chunks, so it does not say whether the first byte ever arrived. Other transport errors, including connect, write and pool timeouts, keep the generic handler and the backend hint, and no partial file is written.tests/test_project_commands.py: newTestProjectLogsTimeout(5 tests): the extended timeout is requested, other commands keep the default, a read timeout gives the new message without the backend hint and writes no file, a refused connection keeps the hint, and connect, write and pool timeouts are not reported as a slow archive.The 300 s is a judgement call. A single execution's log download gets 120 s (
TEST_RUN_EXECUTION_IO_TIMEOUT) and a project is the sum of its executions. It is a constant, easy to adjust once there are timings from larger projects.Not in this PR
The backend still builds the whole archive before it responds and stores it uncompressed (36.1 MB compressed and uncompressed in the case above). Streaming the archive while it is built, and compressing it, would remove the dependency on a timeout altogether; that is a separate backend change.
Testing
tests/test_project_commands.py: 71 passed (66 before, plus the 5 new tests).v2.17-cli-developwithout this change and with it (all in other test files, such astest_run_tests.pyandtest_tc_params_mapping.py, which do not touch this code); 5 more pass with it, the new ones. I did not investigate those 47.isortandflake8are clean for the changed files;blackleavesth_cli/commands/project.pyunchanged.th-cli project logson the project with 12 executions no longer times out.