Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions internal/cli/command_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -443,6 +443,7 @@ func TestCommandIncidentLifecycleHelpDocumentsSafetyAndLookupHints(t *testing.T)
want: []string{
"up to 100 incidents",
"1024 characters",
"wc -m",
},
},
}
Expand DownExpand Up@@ -596,8 +597,12 @@ func TestCommandIncidentCommentRejectsOver1024Runes(t *testing.T) {
if err == nil {
t.Fatal("[incident-comment-too-long] expected an error, got nil")
}
if !strings.Contains(err.Error(), "1024 characters") {
t.Fatalf("[incident-comment-too-long] unexpected error: %v", err)
// The error must name the actual character count and the limit, so whoever
// (or whatever) wrote the over-long comment knows how much to trim.
for _, want := range []string{"1025 characters", "limit is 1024"} {
if !strings.Contains(err.Error(), want) {
t.Fatalf("[incident-comment-too-long] error missing %q: %v", want, err)
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions internal/cli/incident.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -894,7 +894,9 @@ shell, so backticks, $(...), and quotes inside it reach the API exactly as
written. Leading/trailing whitespace is trimmed before sending — matching how
the server stores it, so a bash heredoc's trailing newline (the pattern this
CLI's own skill card recommends) does not fail verification below. The
trimmed text must be non-empty and at most 1024 characters. Use --mute-reply
trimmed text must be non-empty and at most 1024 characters. The limit counts
characters (Unicode runes), not bytes, so multibyte text (e.g. Chinese) is not
penalized — measure with 'wc -m', not 'wc -c'. Use --mute-reply
when the comment should not trigger webhook reply behavior.

After writing, the command reads back every incident's timeline and verifies
Expand DownExpand Up@@ -926,8 +928,8 @@ success.`,
if comment == "" {
return fmt.Errorf("--comment-file must not be empty")
}
if len([]rune(comment)) > 1024 {
return fmt.Errorf("--comment-file content must be at most 1024 characters")
if n := len([]rune(comment)); n > 1024 {
return fmt.Errorf("--comment-file content is %d characters, limit is 1024", n)
}

return runCommand(cmd, args, func(ctx *RunContext) error {
Expand Down