Skip to content

Commit 22a7f15

Browse files
authored
Merge pull request #166 from flashcatcloud/fix/incident-comment-char-cap
fix(incident): clarify comment length cap unit and report actual count
2 parents 675e63e + b893f03 commit 22a7f15

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

internal/cli/command_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ func TestCommandIncidentLifecycleHelpDocumentsSafetyAndLookupHints(t *testing.T)
443443
want: []string{
444444
"up to 100 incidents",
445445
"1024 characters",
446+
"wc -m",
446447
},
447448
},
448449
}
@@ -596,8 +597,12 @@ func TestCommandIncidentCommentRejectsOver1024Runes(t *testing.T) {
596597
if err == nil {
597598
t.Fatal("[incident-comment-too-long] expected an error, got nil")
598599
}
599-
if !strings.Contains(err.Error(), "1024 characters") {
600-
t.Fatalf("[incident-comment-too-long] unexpected error: %v", err)
600+
// The error must name the actual character count and the limit, so whoever
601+
// (or whatever) wrote the over-long comment knows how much to trim.
602+
for _, want := range []string{"1025 characters", "limit is 1024"} {
603+
if !strings.Contains(err.Error(), want) {
604+
t.Fatalf("[incident-comment-too-long] error missing %q: %v", want, err)
605+
}
601606
}
602607
}
603608

internal/cli/incident.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,9 @@ shell, so backticks, $(...), and quotes inside it reach the API exactly as
894894
written. Leading/trailing whitespace is trimmed before sending — matching how
895895
the server stores it, so a bash heredoc's trailing newline (the pattern this
896896
CLI's own skill card recommends) does not fail verification below. The
897-
trimmed text must be non-empty and at most 1024 characters. Use --mute-reply
897+
trimmed text must be non-empty and at most 1024 characters. The limit counts
898+
characters (Unicode runes), not bytes, so multibyte text (e.g. Chinese) is not
899+
penalized — measure with 'wc -m', not 'wc -c'. Use --mute-reply
898900
when the comment should not trigger webhook reply behavior.
899901
900902
After writing, the command reads back every incident's timeline and verifies
@@ -926,8 +928,8 @@ success.`,
926928
if comment == "" {
927929
return fmt.Errorf("--comment-file must not be empty")
928930
}
929-
if len([]rune(comment)) > 1024 {
930-
return fmt.Errorf("--comment-file content must be at most 1024 characters")
931+
if n := len([]rune(comment)); n > 1024 {
932+
return fmt.Errorf("--comment-file content is %d characters, limit is 1024", n)
931933
}
932934

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

0 commit comments

Comments
 (0)