From 9093de7258d76774dd1f8cb8fdb8328b8e954596 Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Sun, 10 May 2026 12:49:38 -0400 Subject: [PATCH] cloudagents: increase scanner buffer to avoid token too long errors bufio.Scanner defaults to a 64KB max token size. Docker build output and agent logs can produce lines longer than that, especially during package installs (e.g. pip), causing "bufio.Scanner: token too long". Bump the max to 4MB in both the build and log scanners. This matches what lk agent deploy --silent users hit in practice. --- pkg/cloudagents/build.go | 1 + pkg/cloudagents/logs.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/cloudagents/build.go b/pkg/cloudagents/build.go index 91d3ce7a..f99523b9 100644 --- a/pkg/cloudagents/build.go +++ b/pkg/cloudagents/build.go @@ -69,6 +69,7 @@ func (c *Client) build(ctx context.Context, id string, environment string, write eg.Go(func() error { defer close(ch) scanner := bufio.NewScanner(resp.Body) + scanner.Buffer(make([]byte, bufio.MaxScanTokenSize), 4*1024*1024) for scanner.Scan() { line := scanner.Text() if strings.HasPrefix(line, "BUILD ERROR:") { diff --git a/pkg/cloudagents/logs.go b/pkg/cloudagents/logs.go index d05ec714..94bd7889 100644 --- a/pkg/cloudagents/logs.go +++ b/pkg/cloudagents/logs.go @@ -61,6 +61,7 @@ func (c *Client) StreamLogs(ctx context.Context, logType, agentID, environment s return fmt.Errorf("failed to get logs: %s - %v", errorResponse.Message, errorResponse.Meta) } scanner := bufio.NewScanner(resp.Body) + scanner.Buffer(make([]byte, bufio.MaxScanTokenSize), 4*1024*1024) for { select { case <-ctx.Done():