Skip to content

Commit fa58c97

Browse files
committed
fix: return error if not all path parameters are passed in
1 parent bce1207 commit fa58c97

File tree

5 files changed

+94
-71
lines changed

5 files changed

+94
-71
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ data, err := fgaClient.WriteAssertions(context.Background()).
10961096
### Calling Other Endpoints
10971097

10981098
In certain cases you may want to call other APIs not yet wrapped by the SDK. You can do so by using the `APIExecutor` available from the `fgaClient`.
1099-
The `APIExecutor` allows you to make raw HTTP calls to any OpenFGA endpoint by specifying the operation name, HTTP method, path, parameters, body, and headers, while still taking into account the configuration and handling authentication, telemetry, retry and error handling.
1099+
The `APIExecutor` allows you to make raw HTTP calls to any OpenFGA endpoint by specifying the operation name, HTTP method, path, parameters, body, and headers, while still honoring the client configuration (authentication, telemetry, retries, and error handling).
11001100

11011101
This is useful when:
11021102

@@ -1123,10 +1123,10 @@ requestBody := map[string]interface{}{
11231123
// Build the request
11241124
request := openfga.NewAPIExecutorRequestBuilder("CustomEndpoint", http.MethodPost, "/stores/{store_id}/custom-endpoint").
11251125
WithPathParameter("store_id", storeID).
1126-
WithQueryParameter("page_size", "20").
1127-
WithQueryParameter("continuation_token", "eyJwayI6...").
1126+
WithQueryParameter("page_size", "20").
1127+
WithQueryParameter("continuation_token", "eyJwayI6...").
11281128
WithBody(requestBody).
1129-
WithHeader("X-Experimental-Feature", "enabled").
1129+
WithHeader("X-Experimental-Feature", "enabled").
11301130
Build()
11311131
```
11321132

@@ -1164,7 +1164,7 @@ type CustomEndpointResponse struct {
11641164
var customEndpointResponse CustomEndpointResponse
11651165

11661166
// Get raw response decoded into CustomEndpointResponse struct
1167-
rawResponse, err := executor.Execute(ctx, request, &customEndpointResponse) // Pass pointer to struct for decoding
1167+
rawResponse, err := executor.ExecuteWithDecode(ctx, request, &customEndpointResponse) // Pass pointer to struct for decoding
11681168

11691169
if err != nil {
11701170
log.Fatalf("Custom endpoint failed: %v", err)
@@ -1175,7 +1175,7 @@ fmt.Printf("Response: %+v\n", customEndpointResponse)
11751175
// You can access fields like headers, status code, etc. from rawResponse:
11761176
fmt.Printf("Status Code: %d\n", rawResponse.StatusCode)
11771177
fmt.Printf("Headers: %+v\n", rawResponse.Headers)
1178-
````
1178+
```
11791179

11801180
### Retries
11811181

api_executor.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ func (e *apiExecutor) executeInternal(ctx context.Context, request APIExecutorRe
274274

275275
// Build request parameters
276276
path := buildPath(request.Path, request.PathParameters)
277+
278+
if strings.Contains(path, "{") || strings.Contains(path, "}") {
279+
return nil, reportError("not all path parameters were provided for path: %s", path)
280+
}
281+
277282
headerParams := prepareHeaders(request.Headers)
278283
queryParams := request.QueryParameters
279284
if queryParams == nil {

0 commit comments

Comments
 (0)