From 58e05cebfc972d9daf53856e839081f0db9fb3fd Mon Sep 17 00:00:00 2001 From: Grey Newell Date: Thu, 9 Apr 2026 13:07:22 -0400 Subject: [PATCH] fix(archdocs): guard against start_line > end_line in source snippet extraction When API data has start_line > end_line, lines[sl-1:el] panics with "slice bounds out of range" because sl-1 > el creates a reversed range. Add sl <= el to the bounds check so malformed line numbers are skipped rather than crashing the build. Co-Authored-By: Claude Sonnet 4.6 --- internal/archdocs/pssg/build/build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/archdocs/pssg/build/build.go b/internal/archdocs/pssg/build/build.go index b8107cb..2d46845 100644 --- a/internal/archdocs/pssg/build/build.go +++ b/internal/archdocs/pssg/build/build.go @@ -468,7 +468,7 @@ func (b *Builder) renderEntityPage( fullPath := filepath.Join(sourceDir, filePath) if data, err := os.ReadFile(fullPath); err == nil { lines := strings.Split(string(data), "\n") - if sl <= len(lines) && el <= len(lines) { + if sl <= el && sl <= len(lines) && el <= len(lines) { sourceCode = strings.Join(lines[sl-1:el], "\n") } }