feat: [CLI-56856]: Add configurable request timeout#94
Open
dtsong-harness wants to merge 4 commits intoharness:mainfrom
Open
feat: [CLI-56856]: Add configurable request timeout#94dtsong-harness wants to merge 4 commits intoharness:mainfrom
dtsong-harness wants to merge 4 commits intoharness:mainfrom
Conversation
…_TIMEOUT env var The HTTP request timeout was hardcoded to 10 seconds across the CLI, causing failures for API calls that legitimately take longer. This adds a --timeout global flag (default 10s) and HARNESS_TIMEOUT environment variable so users can increase the timeout as needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jliu-harness
reviewed
Apr 9, 2026
jliu-harness
reviewed
Apr 9, 2026
jliu-harness
reviewed
Apr 9, 2026
jliu-harness
reviewed
Apr 9, 2026
- Rename env var from HARNESS_TIMEOUT to HARNESS_TIMEOUT_SECONDS for clarity - Error and exit on invalid HARNESS_TIMEOUT_SECONDS value instead of silently ignoring - Remove redundant default in GlobalFlags struct (already set via flag default in main.go) - Revert login.go to hardcoded 10s timeout since it's a one-off client Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jliu-harness
approved these changes
Apr 9, 2026
jliu-harness
reviewed
Apr 9, 2026
| config.Global.ProjectID = envVal | ||
| } | ||
| if envVal := os.Getenv("HARNESS_TIMEOUT_SECONDS"); envVal != "" { | ||
| timeout, err := strconv.Atoi(envVal) |
There was a problem hiding this comment.
This is user input. So a sanity check on the value range may be useful. timeout should be within a range, maybe [0, 3600]? I don't think the server will have a timeout of 1 hour.
Validates --timeout flag and HARNESS_TIMEOUT_SECONDS are within [0, 3600] to prevent unreasonable timeout values from user input. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jliu-harness
approved these changes
Apr 10, 2026
Remove max timeout cap and default to 0 (no timeout) since long-running commands like migrations need unbounded time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jliu-harness
approved these changes
Apr 10, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
--timeoutglobal flag (default: no timeout) to configure the HTTP request timeout for API callsHARNESS_TIMEOUT_SECONDSenvironment variable as an alternative to the flagutil/client/iacm/iacm-client.goMotivation
The 10-second hardcoded timeout causes failures for API calls that legitimately take longer (e.g., large account queries, migration jobs, slow network conditions). Users currently have no way to increase this without switching to raw
curlcalls.By defaulting to no timeout (0), long-running commands like migrations work out of the box, while users can set a timeout if desired.
Usage
Changes
config/globals.goTimeoutSecondsfield andDefaultTimeoutSecondsconstant (default: 0)cmd/hc/main.go--timeoutpersistent flag,HARNESS_TIMEOUT_SECONDSenv var, and input validationutil/client/iacm/iacm-client.goTest plan
go build ./cmd/hc/compiles successfullygo test ./...— all existing tests passhc --helpshows--timeoutflag with "default: no timeout"hc --timeout 30 iacm plan ...uses 30s timeoutHARNESS_TIMEOUT_SECONDS=30 hc iacm plan ...uses 30s timeout🤖 Generated with Claude Code