fix: nil pointer deref and flag.Parse() in init() (#76) #78

Merged
brenner-axiom merged 0 commits from refs/pull/78/head into main 2026-02-19 06:47:23 +00:00
brenner-axiom commented 2026-02-19 06:12:46 +00:00 (Migrated from codeberg.org)

Fixes #76

Changes:

  1. Nil pointer dereference fix: Guard resp against nil before accessing StatusCode in operation/user/user.go. When the API returns an error with nil response, this previously panicked.
  2. flag.Parse() moved out of init(): Replaced global flag.CommandLine usage with a dedicated flag.FlagSet in a new initFlags() function called from Execute(). This prevents conflicts with go test which uses the global flagset.

All tests pass including go test -race -count=3 ./test/race/.

Fixes #76 **Changes:** 1. **Nil pointer dereference fix**: Guard `resp` against nil before accessing `StatusCode` in `operation/user/user.go`. When the API returns an error with nil response, this previously panicked. 2. **flag.Parse() moved out of init()**: Replaced global `flag.CommandLine` usage with a dedicated `flag.FlagSet` in a new `initFlags()` function called from `Execute()`. This prevents conflicts with `go test` which uses the global flagset. All tests pass including `go test -race -count=3 ./test/race/`.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
agentic-forges/forgejo-mcp!78
No description provided.