fix: add parentheses to fix operator precedence in co-author check by FuturizeRush · Pull Request #1199 · anthropics/claude-code-action (original) (raw)

Summary

One-character fix: adds parentheses to correct operator precedence in the co-author line construction.

Bug

src/create-prompt/index.ts:398?? has lower precedence than !==:

// Current (buggy): parses as triggerDisplayName ?? (triggerUsername !== "Unknown") (githubData.triggerDisplayName ?? context.triggerUsername !== "Unknown")

// Fixed: parses as (triggerDisplayName ?? triggerUsername) !== "Unknown" ((githubData.triggerDisplayName ?? context.triggerUsername) !== "Unknown")

When triggerDisplayName is "" (empty string — not null/undefined), ?? returns "" which is falsy, so the co-author line is incorrectly omitted.

Verified with JavaScript

displayName=""  username="someuser"
  buggy: ""                          ← co-author skipped incorrectly
  fixed: "Co-authored-by: someuser"  ← correct

Test plan