Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
51b7653
feat(discussion/client): add discussion client package
babakks Jun 1, 2026
d3a1538
feat(discussion/shared): add shared utilities for discussion commands
babakks Jun 1, 2026
8b73951
feat(discussion list): add discussion list command
babakks Jun 1, 2026
57008e7
feat(discussion view): add discussion view command
babakks Jun 1, 2026
7bd67a8
feat(discussion create): add discussion create command
babakks Jun 1, 2026
797effe
feat(discussion edit): add discussion edit command
babakks Jun 1, 2026
dc5d7c1
fix(discussion): various polish and small fixes
babakks Jun 4, 2026
0d93148
refactor(discussion): extract command-level consts for enums
babakks Jun 4, 2026
97b2296
refactor(discussion list): make pager call/error consistent with view…
babakks Jun 4, 2026
dcd3507
docs(discussion/client): add godoc to exported consts
babakks Jun 4, 2026
d6a089d
chore(discussion/client): fix formatting
babakks Jun 4, 2026
b102900
fix(discussion): handle partial failure on create/update label mutations
babakks Jun 5, 2026
6dcb0b0
docs(discussion view): improve long help text for clarity
babakks Jun 5, 2026
fbd733e
refactor(discussion): add Cursor field and ExportData to DiscussionLi…
babakks Jun 5, 2026
e104885
refactor(discussion/client): precheck discussions enabled via getRepo…
babakks Jun 5, 2026
ca8e126
fix(discussion list): print "answered" instead of checkmark in non-tt…
babakks Jun 5, 2026
ada8583
test(discussion): add acceptance tests for discussion commands
babakks Jun 5, 2026
8ec0830
docs(acceptance): add new jq2env and jq-assert functions
babakks Jun 5, 2026
f147d02
test(discussion list): consolidate tests into table-driven format
babakks Jun 5, 2026
e61df07
Merge branch 'trunk' into feature/discussion
babakks Jun 5, 2026
c1f3c1a
fix(discussion): add missing repo flag override
babakks Jun 8, 2026
9d413e7
test(discussion list): rename TestNewCmdList2 to TestNewCmdList
babakks Jun 9, 2026
e2d150d
fix(discussion): remove redundant error wrapping on ListCategories
babakks Jun 9, 2026
95fc89c
chore(discussion): remove unused HttpClient field from create and edit
babakks Jun 9, 2026
4166ecf
chore: apply formatting
babakks Jun 9, 2026
2618999
feat(discussion/client): add comment manipulation methods
babakks Jun 6, 2026
6f5e114
feat(discussion): add discussion comment command
babakks Jun 8, 2026
82ac0d7
refactor(acceptance): use discussion comment command instead of raw A…
babakks Jun 8, 2026
2629753
test(acceptance): add discussion comment acceptance test
babakks Jun 8, 2026
61a4476
test(discussion comment): add non-tty delete flag validation test case
babakks Jun 8, 2026
d026f8f
feat(discussion): support comment URLs in --replies and comment command
babakks Jun 8, 2026
6394ca8
test(acceptance): cover discussion comment URLs in comment and view t…
babakks Jun 8, 2026
bc7ed48
chore: fix formatting
babakks Jun 8, 2026
55928c9
refactor(discussion view): replace --replies flag with positional com…
babakks Jun 10, 2026
8747c69
refactor(discussion/client): take host instead of repo in GetComment
babakks Jun 10, 2026
869c044
test(acceptance): use positional comment argument in discussion view …
babakks Jun 10, 2026
8d2b059
fix(discussion view): error when --comments is used with a comment ar…
babakks Jun 10, 2026
42db02d
Merge pull request #13620 from cli/babakks/add-discussion-comment
babakks Jun 10, 2026
27aabfa
fix(discussion view): use color scheme method for success icon
babakks Jun 10, 2026
951d76e
refactor(discussion list): simplify no-results message and use succes…
babakks Jun 10, 2026
9f2da11
fix(discussion view): show comments and replies in chronological order
babakks Jun 10, 2026
06d2e34
docs(discussion list): clarify answered examples refer to Q&A discuss…
babakks Jun 10, 2026
5d77247
fix(discussion view): print only requested items in non-tty output
babakks Jun 10, 2026
d63ab8d
fix(discussion/shared): error on out-of-range discussion number in URL
babakks Jun 10, 2026
5e6a58b
test(acceptance): fix discussion comment acceptance tests
babakks Jun 10, 2026
616d929
chore(discussion/client): rename client files
babakks Jun 10, 2026
69855b7
fix(discussion comment): fix bug in requiring body/body-file in add/e…
babakks Jun 10, 2026
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
Prev Previous commit
Next Next commit
fix(discussion/shared): error on out-of-range discussion number in URL
The discussion URL pattern captures one or more digits, which can exceed
the int32 range. The parse error from strconv.ParseInt was previously
discarded, silently clamping the number. Return an explicit error
instead, and cover it with tests in both URL parsing functions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
babakks and Copilot committed Jun 10, 2026
commit d63ab8ddd8696194f3fd49a726eb6d60dd3cdfa5
11 changes: 9 additions & 2 deletions pkg/cmd/discussion/shared/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ func ParseDiscussionArg(arg string) (int32, ghrepo.Interface, error) {
return 0, nil, fmt.Errorf("invalid discussion URL: %q", arg)
}

num, _ := strconv.ParseInt(m[3], 10, 32)
num, err := strconv.ParseInt(m[3], 10, 32)
if err != nil {
return 0, nil, fmt.Errorf("invalid discussion number in URL: %q", m[3])
}

repo := ghrepo.NewWithHost(m[1], m[2], u.Hostname())
return int32(num), repo, nil
}
Expand Down Expand Up @@ -84,7 +88,10 @@ func ParseDiscussionOrCommentArg(arg string) (*ParsedDiscussionOrCommentArg, err
return nil, fmt.Errorf("invalid discussion URL: %q", arg)
}

num, _ := strconv.ParseInt(m[3], 10, 32)
num, err := strconv.ParseInt(m[3], 10, 32)
if err != nil {
return nil, fmt.Errorf("invalid discussion number in URL: %q", m[3])
}
repo := ghrepo.NewWithHost(m[1], m[2], u.Hostname())

if fragment := u.Fragment; strings.HasPrefix(fragment, "discussioncomment-") {
Expand Down
10 changes: 10 additions & 0 deletions pkg/cmd/discussion/shared/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func TestParseDiscussionArg(t *testing.T) {
arg: "https://github.com/owner/repo/discussions/",
wantErr: `invalid discussion URL: "https://github.com/owner/repo/discussions/"`,
},
{
name: "URL with overflowing number",
arg: "https://github.com/owner/repo/discussions/99999999999999999999",
wantErr: `invalid discussion number in URL: "99999999999999999999"`,
},
{
name: "zero",
arg: "0",
Expand Down Expand Up @@ -166,6 +171,11 @@ func TestParseDiscussionOrCommentArg(t *testing.T) {
arg: "https://github.com/owner/repo/discussions/",
wantErr: `invalid discussion URL: "https://github.com/owner/repo/discussions/"`,
},
{
name: "URL with overflowing number",
arg: "https://github.com/owner/repo/discussions/99999999999999999999",
wantErr: `invalid discussion number in URL: "99999999999999999999"`,
},
{
name: "comment URL with invalid fragment",
arg: "https://github.com/owner/repo/discussions/5#discussioncomment-abc",
Expand Down
Loading