Skip to content

Commit 8373bce

Browse files
committed
fix(skill): harden heredoc delimiter
1 parent 7af84fc commit 8373bce

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

internal/skilldoc/incident_comment_guidance_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestIncidentCardCommentWorkflow(t *testing.T) {
1616
}
1717

1818
body := string(card)
19-
quotedHeredoc := "COMMENT=$(cat <<'COMMENT_EOF'"
19+
quotedHeredoc := "COMMENT=$(cat <<'FDUTY_COMMENT_7F3A9C2E_EOF'"
2020
commentCommand := `fduty incident comment "$ID" --comment "$COMMENT"`
2121
timelineCommand := `fduty incident timeline "$ID" --output-format toon`
2222

@@ -36,6 +36,9 @@ func TestIncidentCardCommentWorkflow(t *testing.T) {
3636
if !strings.Contains(body, "After every comment write, read back every target and verify the intended comment is present before reporting success.") {
3737
t.Error("incident card must require content-fidelity verification after every comment write")
3838
}
39+
if !strings.Contains(body, "choose a fresh delimiter that is absent as a full line in the intended comment") {
40+
t.Error("incident card must require a collision-free heredoc delimiter")
41+
}
3942
if strings.Contains(body, `fduty incident comment <incident-id> --comment "Root cause identified: DB failover. Fix deploying."`) {
4043
t.Error("incident card must not retain the unsafe inline comment example")
4144
}
@@ -51,11 +54,12 @@ func TestIncidentCommentQuotedHeredocPreservesMarkdown(t *testing.T) {
5154
}
5255
5356
ID=64b64ca26f84f00000000000
54-
COMMENT=$(cat <<'COMMENT_EOF'
57+
COMMENT=$(cat <<'FDUTY_COMMENT_7F3A9C2E_EOF'
5558
## Investigation
5659
Use ` + "`kubectl get pod`" + ` to inspect the restart.
57-
The follow-up is still pending.
5860
COMMENT_EOF
61+
The follow-up is still pending.
62+
FDUTY_COMMENT_7F3A9C2E_EOF
5963
)
6064
fduty incident comment "$ID" --comment "$COMMENT"
6165
`
@@ -65,7 +69,7 @@ fduty incident comment "$ID" --comment "$COMMENT"
6569
t.Fatalf("Bash fixture failed: %v\n%s", err, output)
6670
}
6771

68-
want := "## Investigation\nUse `kubectl get pod` to inspect the restart.\nThe follow-up is still pending."
72+
want := "## Investigation\nUse `kubectl get pod` to inspect the restart.\nCOMMENT_EOF\nThe follow-up is still pending."
6973
if got := string(output); got != want {
7074
t.Errorf("comment content changed:\nwant: %q\n got: %q", want, got)
7175
}

skills/flashduty/reference/incident.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ fduty incident ack <incident-id>
5858

5959
# 6. Post a status comment safely, then read it back
6060
ID=<incident-id>
61-
COMMENT=$(cat <<'COMMENT_EOF'
61+
# Before running, choose a fresh delimiter that is absent as a full line in the intended comment.
62+
COMMENT=$(cat <<'FDUTY_COMMENT_7F3A9C2E_EOF'
6263
Root cause identified: DB failover.
6364
Fix deploying.
64-
COMMENT_EOF
65+
FDUTY_COMMENT_7F3A9C2E_EOF
6566
)
6667
fduty incident comment "$ID" --comment "$COMMENT"
6768
fduty incident timeline "$ID" --output-format toon

0 commit comments

Comments
 (0)