reliability: treat zero http.Client timeouts as unbounded - #144
Merged
Conversation
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.
Motivation
http.Clientcomposite literal with aTimeoutkey was classified as bounded even when the value represented a zero/unbounded duration.Description
isHTTPClientWithTimeoutininternal/codeguard/checks/reliability/reliability_go_helpers.goto verify theTimeoutvalue is not a syntactic zero by calling a new helperisZeroDurationinstead of simply checking for the presence of theTimeoutkey.isZeroDurationhelper that detects zero durations for common AST patterns including parenthesized/signed zeros, integer literals,time.Duration(0)conversions, and simple binary expressions like0 * time.Second.go/tokenandmath/bigto support AST token checks and integer parsing.TestReliabilityGoFlagsZeroClientTimeoutintests/checks/reliability_test.gothat assertsreliability.missing-timeoutis reported forTimeout: 0,Timeout: time.Duration(0), andTimeout: 0 * time.Secondwhile preserving existing bounded-timeout behavior.Testing
gofmt -won the modified files which completed successfully.go test ./tests/checks -run 'TestReliabilityGo(FlagsZeroClientTimeout|DoesNotFlagBoundedHTTPWithContextAndCleanup)$'and the tests passed.go test ./...and it completed successfully, confirming the regression test and existing checks pass.Codex Task