Skip to content

Commit 0f43ac7

Browse files
authored
chore: stack trace for failed change detection (#1799)
## Why When SDK changelog generation fails due to a panic, e.g.: a nil pointer exception, we swallow the stack trace and log an error. ## What changed? Extended the logged error with stack trace after recovery. This helps us find the root cause of changelog detection issues.
1 parent a2d7afd commit 0f43ac7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

internal/sdkchangelog/sdkChangelog.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sdkchangelog
33
import (
44
"context"
55
"fmt"
6+
"runtime/debug"
67

78
changes "github.com/speakeasy-api/openapi-generation/v2/pkg/changes"
89
"github.com/speakeasy-api/speakeasy/internal/log"
@@ -21,7 +22,8 @@ type Requirements struct {
2122
func ComputeAndStoreSDKChangelog(ctx context.Context, changelogRequirements Requirements) (changelogContent string, err error) {
2223
defer func() {
2324
if r := recover(); r != nil {
24-
log.From(ctx).Errorf("Panic recovered in ComputeAndStoreSDKChangelog: %v", r)
25+
stackTrace := string(debug.Stack())
26+
log.From(ctx).Errorf("Panic recovered in ComputeAndStoreSDKChangelog: %v\nStack trace:\n%s", r, stackTrace)
2527
changelogContent = ""
2628
err = fmt.Errorf("panic occurred during SDK changelog generation: %v", r)
2729
}

0 commit comments

Comments
 (0)