Skip to content

Commit db18391

Browse files
authored
Add missing format strings to logging calls (#36192)
1 parent 6251f10 commit db18391

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

sdks/go/container/tools/buffered_logging.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (b *BufferedLogger) FlushAtError(ctx context.Context) {
7878
return
7979
}
8080
for _, message := range b.logs {
81-
b.logger.Errorf(ctx, message)
81+
b.logger.Errorf(ctx, "%s", message)
8282
}
8383
b.logs = nil
8484
b.lastFlush = time.Now()
@@ -91,7 +91,7 @@ func (b *BufferedLogger) FlushAtDebug(ctx context.Context) {
9191
return
9292
}
9393
for _, message := range b.logs {
94-
b.logger.Printf(ctx, message)
94+
b.logger.Printf(ctx, "%s", message)
9595
}
9696
b.logs = nil
9797
b.lastFlush = time.Now()

sdks/go/container/tools/logging_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestLogger(t *testing.T) {
8585

8686
catcher.err = errors.New("test error")
8787
wantMsg := "checking for error?"
88-
l.Printf(ctx, wantMsg)
88+
l.Printf(ctx, "%s", wantMsg)
8989

9090
line, err := buf.ReadString('\n')
9191
if err != nil {

sdks/go/pkg/beam/runners/dataflow/dataflowlib/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func WaitForCompletion(ctx context.Context, client *df.Service, project, region,
262262
if err != nil {
263263
return err
264264
}
265-
log.Infof(ctx, msg)
265+
log.Infof(ctx, "%s", msg)
266266
if terminal {
267267
return nil
268268
}

sdks/python/container/boot.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func launchSDKProcess() error {
188188
if err != nil {
189189
fmtErr := fmt.Errorf("failed to retrieve staged files: %v", err)
190190
// Send error message to logging service before returning up the call stack
191-
logger.Errorf(ctx, fmtErr.Error())
191+
logger.Errorf(ctx, "%s", fmtErr.Error())
192192
// No need to fail the job if submission_environment_dependencies.txt cannot be loaded
193193
if strings.Contains(fmtErr.Error(), "submission_environment_dependencies.txt") {
194194
logger.Printf(ctx, "Ignore the error when loading submission_environment_dependencies.txt.")
@@ -214,7 +214,7 @@ func launchSDKProcess() error {
214214
if setupErr := installSetupPackages(ctx, logger, fileNames, dir, requirementsFiles); setupErr != nil {
215215
fmtErr := fmt.Errorf("failed to install required packages: %v", setupErr)
216216
// Send error message to logging service before returning up the call stack
217-
logger.Errorf(ctx, fmtErr.Error())
217+
logger.Errorf(ctx, "%s", fmtErr.Error())
218218
return fmtErr
219219
}
220220

@@ -500,6 +500,6 @@ func logSubmissionEnvDependencies(ctx context.Context, bufLogger *tools.Buffered
500500
if err != nil {
501501
return err
502502
}
503-
bufLogger.Printf(ctx, string(content))
503+
bufLogger.Printf(ctx, "%s", string(content))
504504
return nil
505505
}

0 commit comments

Comments
 (0)