Skip to content

Commit

Permalink
fix decoding problem
Browse files Browse the repository at this point in the history
  • Loading branch information
jessieqliu committed Oct 12, 2024
1 parent 6a11024 commit 605f0ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions launcher/internal/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ func (l *logger) Error(msg string, args ...any) {
// Write implements the Writer interface for workload logging redirection.
func (l *logger) Write(p []byte) (int, error) {
// Base64 decode input.
var decodedMessage []byte
_, err := base64.RawStdEncoding.Decode(decodedMessage, p)
decodedMessage := make([]byte, base64.StdEncoding.DecodedLen(len(p)))
n, err := base64.StdEncoding.Decode(decodedMessage, p)
if err != nil {
return 0, fmt.Errorf("error decoding message for cloud logging: %v", err)
}

pl := payload{payloadMessageKey: decodedMessage}
pl := payload{payloadMessageKey: decodedMessage[:n]}

if len(l.instanceName) > 0 {
pl[payloadInstanceNameKey] = l.instanceName
Expand Down

0 comments on commit 605f0ff

Please sign in to comment.