From 94b42c7037101c48cb522d321dbe72896d39c0ea Mon Sep 17 00:00:00 2001 From: Homme Zwaagstra Date: Wed, 5 Nov 2025 17:44:19 +0000 Subject: [PATCH] fix: Handle leading whitespace in elided frames marker The stack trace elision marker "...N frames elided..." can appear with leading whitespace (tabs/spaces) in deep call stacks, particularly from AWS SDK v2 middleware chains (33+ frames). The parser was only checking for lines starting with "...", causing it to pass indented elision markers to parseFuncName(), which panicked with "no function found". This fix trims whitespace before checking for the elision marker pattern, allowing both indented and non-indented markers to be handled gracefully. Example stack trace triggering the issue (Go 1.25.1): github.com/aws/aws-sdk-go-v2/service/sqs.(*disableHTTPSMiddleware).HandleFinalize(...) /go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/sqs@v1.42.11/api_client.go:864 +0x143 ...33 frames elided... github.com/aws/aws-sdk-go-v2/aws/middleware.ClientRequestID.HandleBuild(...) /go/pkg/mod/github.com/aws/aws-sdk-go-v2@v1.39.4/aws/middleware/middleware.go:42 +0x1e5 --- internal/stack/stacks.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/stack/stacks.go b/internal/stack/stacks.go index 1d31288..ab256af 100644 --- a/internal/stack/stacks.go +++ b/internal/stack/stacks.go @@ -158,8 +158,10 @@ func (p *stackParser) parseStack(line string) (Stack, error) { // Just skip it. continue } - if strings.HasPrefix(line, "...") && strings.HasSuffix(line, " frames elided...") { - // e.g. ...23 frames elided... + + trimmedLine := strings.TrimSpace(line) + if strings.HasPrefix(trimmedLine, "...") && strings.HasSuffix(trimmedLine, " frames elided...") { + // e.g. "...23 frames elided..." or " ...23 frames elided..." // This indicates frames were elided from the stack trace, // attempting to parse them via parseFuncName will fail resulting in a panic // and a relatively useless output. Gracefully handle this.