Skip to content

Commit a01d8dc

Browse files
authored
Bazel Credential Helper Bugfix Time Format Issue (#633)
* Bugfix Time Format Issue Bugfix time conversion issue when converting from time.RFC3339 to time.UnixDate as this is problematic because RFC3339 is a standardized, unambiguous format with timezone information (e.g., "2023-01-01T12:00:00Z"), while UnixDate is a human-readable format without explicit timezone indicators (e.g., "Sun Jan 1 12:00:00 GMT 2023"). This conversion can lead to timezone ambiguity and parsing errors in systems expecting RFC3339 format, potentially causing authentication failures. Convert to UTC to avoid parsing errors when timezone can't be determined. * Incorporate Review Feedback Switch to much simpler construct..
1 parent 23d034e commit a01d8dc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

go/cmd/bazelcredswrapper/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ func main() {
5454
log.Error(err)
5555
os.Exit(1)
5656
}
57+
58+
// Time format conversion note: Converting from time.RFC3339 to time.UnixDate is
59+
// problematic because RFC3339 is a standardized, unambiguous format with timezone
60+
// information (e.g., "2023-01-01T12:00:00Z"), while UnixDate is a human-readable
61+
// format without explicit timezone indicators (e.g., "Sun Jan 1 12:00:00 GMT 2023").
62+
// This conversion can lead to timezone ambiguity and parsing errors and potentially
63+
// causing authentication failures.
64+
// Convert to UTC to avoid parsing errors when timezone can't be determined.
5765
fmt.Printf(`{"headers":%s, "token":"%s", "expiry":"%s"}`, jsonHdrs,
58-
"", expiry.Format(time.UnixDate))
66+
"", expiry.UTC().Format(time.UnixDate))
5967
}
6068

6169
type CredshelperOut struct {

0 commit comments

Comments
 (0)