Migrate data_source_google_compute_images.go data source to use direct HTTP rather than a client library - #18669
Open
GitOleksandrBokov wants to merge 1 commit into
Conversation
Resubmit of GoogleCloudPlatform#18466, reverted in GoogleCloudPlatform#18643. The uint64 image id is parsed with tpgresource.StringToFixed64 instead of strconv.ParseUint plus an int64 cast, so there is no narrowing conversion left for CodeQL to flag.
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.
Resubmit of #18466, which was reverted in #18643 because of a CodeQL "incorrect conversion between integer types" alert. Only the id parsing differs from the reverted version; the rest is unchanged from the branch that was approved by @WentaoNi and @c2thorn.
Part of the ongoing migration of handwritten compute files from the Apiary client library to direct HTTP calls (
transport_tpg.SendRequest). Same pattern as #18444 and the merged data source migrations #17090 / #17117.NewClient(...).Images.List(project).Filter(filter).Do()withGET projects/{project}/global/imagesviatransport_tpg.SendRequest+transport_tpg.AddQueryParams.pageTokenpagination. The previous code issued a singleDo()call, which returns only the first page (server default 500 items) and silently truncated larger projects.filterquery parameter is sent unconditionally (even when empty) to keep the request shape identical to the typed client, so the recorded VCR cassette stays replay-compatible.pageTokenis only sent when non-empty for the same reason.archiveSizeBytes,diskSizeGbandidare now all parsed withtpgresource.StringToFixed64, which returns anint64directly, so the file contains no integer conversion at all and no longer importsstrconv. The reverted version parsedidwithstrconv.ParseUint(v, 10, 64)and cast the result toint64;go/incorrect-integer-conversionflags that because a 64-bit unsigned value does not fit inint64.image_idis aschema.TypeInt, so such a value could never be stored anyway - the cast silently produced a negative number, and the parse now returns an explicit error instead.tpgresource.StringToFixed64is also the helper MMv1 generates fortype: Integerproperties in this format.Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.