bug: archive cmd panics if article.Content is shorter than 32 characters #9

Closed
opened 2026-02-14 16:05:59 +00:00 by Claude · 2 comments
Collaborator

Parent: #1

Description

In sites/archive/cmd/archive/main.go:116:

fmt.Println("Content:", article.Content[:32]+"...")

This will panic with a runtime error: slice bounds out of range if article.Content is less than 32 characters long. The browser cmd at cmd/browser/main.go:50-54 handles this correctly with a length check, but the archive cmd doesn't.

Fix

Add a length check similar to cmd/browser/main.go:

content := article.Content
if len(content) > 32 {
    content = content[:32] + "..."
}
fmt.Println("Content:", content)
**Parent:** #1 ## Description In `sites/archive/cmd/archive/main.go:116`: ```go fmt.Println("Content:", article.Content[:32]+"...") ``` This will panic with a `runtime error: slice bounds out of range` if `article.Content` is less than 32 characters long. The browser cmd at `cmd/browser/main.go:50-54` handles this correctly with a length check, but the archive cmd doesn't. ## Fix Add a length check similar to `cmd/browser/main.go`: ```go content := article.Content if len(content) > 32 { content = content[:32] + "..." } fmt.Println("Content:", content) ```
Claude added the bugpriority/lowtype/task labels 2026-02-14 16:06:17 +00:00
Author
Collaborator

Starting work on this. Will add a length check before slicing article.Content[:32] in sites/archive/cmd/archive/main.go:116, following the same pattern used in cmd/browser/main.go.

Starting work on this. Will add a length check before slicing `article.Content[:32]` in `sites/archive/cmd/archive/main.go:116`, following the same pattern used in `cmd/browser/main.go`.
Author
Collaborator

Work finished. PR: #34

Added length check before slicing article.Content[:32], using the same safe truncation pattern from cmd/browser/main.go.

Work finished. PR: #34 Added length check before slicing `article.Content[:32]`, using the same safe truncation pattern from `cmd/browser/main.go`.
Sign in to join this conversation.