fix: use issue.number instead of issue.id in comment command #256
No reviewers
Labels
No labels
actions
bug
build
chore
CI
cleanup
CLI
contribution welcome
docs
duplicate
enhancement
feature
fix
good first issue
help wanted
invalid
perf
question
refactor
release
revert
style
test
tracking
UI
upstream
UX
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Aviac/codeberg-cli!256
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "timstoop/codeberg-cli:fix-issue-comment-404"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #224 where
berg issue commentreturned a 404 error when the issue's internal database ID differed from its visible issue number.Problem
The
issue commentcommand was usingissue.id(internal database ID) instead ofissue.number(the visible issue number like #1, #2, etc.) when making the API call. The Forgejo API expects the issue number, not the internal ID.When these values differ (which happens in repositories with closed/deleted issues), the API returns a 404 error.
Solution
Changed
src/actions/issue/comment.rs:93to useissue.numberinstead ofissue.id, aligning with how other commands likeissue editalready work.Testing
Related
This fix aligns with the pattern used in other commands:
issue editusesissue.number(line 76)milestone viewusesissue.number(line 106)Closes #224
🤖 Generated with Claude Code
While reviewing the codebase, we found the same bug in
berg issue view --comments(both JSON and Pretty output modes). The view command was also usingissue.idinstead ofissue.numberwhen fetching comments.Since this is the exact same root cause (API expects issue numbers, not internal database IDs), I've added the fix to this PR along with a test case that would have caught both bugs.
Changes in the latest commit:
src/actions/issue/view.rs:88(JSON output mode)src/actions/issue/view.rs:144(Pretty output mode)issueViewCommentsWithDifferentIdAndNumberSplit the fix for view.rs off into its own branch, to keep the reviewing as focussed as possible.
Sorry for how this went here. I just now realize that you also tackled the issue. I was writing a test which could properly reproduce the issue since this was non trivial. The fix itself is now already merged!
Pull request closed