go-sdk icon indicating copy to clipboard operation
go-sdk copied to clipboard

Add nil-check validation in CreateStoreExecute

Open coderabbitai[bot] opened this issue 1 month ago • 0 comments
trafficstars

Description

The CreateStoreExecute method in client/client.go calls request.GetBody().Name without checking whether GetBody() returns nil, which can cause a panic.

Also there are other methods with the same issue - go through them and make sure any that need fixing is fixed.

Recommendation

Add validation to check if request.GetBody() is nil before accessing Name. If nil, return a FgaRequiredParamError with param "body" to provide a graceful error instead of a nil-dereference panic. Add tests to cover the scenarios that body is nil for all relevant methods

References

  • PR: https://github.com/openfga/go-sdk/pull/233
  • Comment: https://github.com/openfga/go-sdk/pull/233#discussion_r2359562337
  • Requested by: @rhamzeh

Location

File: client/client.go Lines: ~691-705 (CreateStoreExecute function)

coderabbitai[bot] avatar Oct 02 '25 15:10 coderabbitai[bot]