chore: reverse sync go-sdk#707
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR adds streaming support for list operations to the Go SDK generator via conditional ChangesGo SDK streaming and documentation expansion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Synchronizes the SDK generator’s Go client templates/config with the current state of openfga/go-sdk, including updated docs and the newer streaming/executor patterns.
Changes:
- Adds conditional “Calling Other Endpoints” documentation (and TOC placement) to generated READMEs.
- Updates Go templates to use the API executor + streaming channel patterns and refreshes Go streaming tests accordingly.
- Bumps Go SDK package version and adds a Go-specific CONTRIBUTING guide template.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| config/common/files/README.mustache | Adds a conditional “Calling Other Endpoints” section and adjusts TOC ordering. |
| config/clients/go/template/streaming.mustache | Removes prior streaming helper implementations from the generated streaming.go template. |
| config/clients/go/template/streaming_test.mustache | Updates tests to use the OpenFgaApi.StreamedListObjects(...).Execute() flow and adds nil-response/body test cases. |
| config/clients/go/template/README_calling_other_endpoints.mustache | New Go README content documenting APIExecutor raw + streaming calls. |
| config/clients/go/template/internal/constants.mustache | Adjusts Go User-Agent constant construction. |
| config/clients/go/template/CONTRIBUTING.md.mustache | Adds a Go SDK-specific contributing guide template. |
| config/clients/go/template/api.mustache | Adds streaming request options + streamed execution returning a typed channel backed by APIExecutor.ExecuteStreaming. |
| config/clients/go/config.overrides.json | Bumps Go package version and enables calling-other-endpoints docs + hides BatchCheck TOC. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
config/clients/go/template/api.mustache (2)
255-255: 💤 Low valueStreaming
Execute()usesBufferSize: 0whenOptions()is not called.If a caller invokes
.Body(...).Execute()without.Options(StreamingRequestOptions{...}),r.options.BufferSizeis0, producing an unbuffered raw channel and, downstream, an unbufferedObjectschannel. The docs recommendDefaultStreamBufferSize. Consider defaulting to a sane buffer size when unset.♻️ Optional default
- rawChannel, err := executor.ExecuteStreaming(r.ctx, request, r.options.BufferSize) + bufferSize := r.options.BufferSize + if bufferSize <= 0 { + bufferSize = DefaultStreamBufferSize + } + rawChannel, err := executor.ExecuteStreaming(r.ctx, request, bufferSize)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@config/clients/go/template/api.mustache` at line 255, When calling executor.ExecuteStreaming you currently pass r.options.BufferSize which can be 0 when .Options(...) wasn't called; ensure you default to a sane buffer by checking r.options.BufferSize and substituting DefaultStreamBufferSize when it's zero before calling executor.ExecuteStreaming (e.g. compute buf := r.options.BufferSize; if buf == 0 { buf = DefaultStreamBufferSize } and pass buf or set r.options.BufferSize = buf), referencing rawChannel, executor.ExecuteStreaming, r.options.BufferSize, and DefaultStreamBufferSize.
131-152: ⚖️ Poor tradeoffHardcoded
StreamedListObjects*declarations make the Go streaming template non-reusable across multiplex-streamingoperations
StreamedListObjectsChannel/convertToStreamedListObjectsChannelare emitted inside{{#operation}}{{#vendorExtensions.x-streaming}}, so if a second operation ever setsx-streaming, this template would generate duplicate package-scope type/function names and fail to compile (latent until additional streaming endpoints are added).Also,
{{vendorExtensions.x-streaming-response-type}}is only referenced in a comment (around line 260), while the implementation is hardcoded toStreamedListObjectsResponse(e.g.,var response StreamedListObjectsResponse,Objects chan StreamedListObjectsResponse). Prefer deriving the response/channel element type fromvendorExtensions.x-streaming-response-type(and parameterizing the helper/type names similarly), especially in the 260-321 range.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@config/clients/go/template/api.mustache` around lines 131 - 152, The template currently emits package-level symbols like StreamedListObjectsChannel and convertToStreamedListObjectsChannel with a hardcoded element type StreamedListObjectsResponse which will collide if multiple operations use x-streaming; update the mustache generation to parameterize these names and the channel element type from vendorExtensions.x-streaming-response-type (and/or operation identifier) so each streaming operation gets unique types/functions (e.g., derive Channel type name and convert function name from the operationId or vendorExtensions key), replace all occurrences of StreamedListObjectsResponse with the vendorExtensions.x-streaming-response-type reference, and ensure Close/cancel behavior remains the same; this removes global name conflicts and makes the template reusable for multiple x-streaming operations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@config/clients/go/template/README_calling_other_endpoints.mustache`:
- Around line 94-99: Replace the deprecated openfga.PtrString usage in the
streaming example with the generic helper openfga.ToPtr to follow the new
convention: update the WithBody call that sets AuthorizationModelId from
openfga.PtrString(modelID) to use openfga.ToPtr (e.g.,
openfga.ToPtr[string](modelID)), so the example in
README_calling_other_endpoints.mustache uses the recommended helper for pointer
values.
---
Nitpick comments:
In `@config/clients/go/template/api.mustache`:
- Line 255: When calling executor.ExecuteStreaming you currently pass
r.options.BufferSize which can be 0 when .Options(...) wasn't called; ensure you
default to a sane buffer by checking r.options.BufferSize and substituting
DefaultStreamBufferSize when it's zero before calling executor.ExecuteStreaming
(e.g. compute buf := r.options.BufferSize; if buf == 0 { buf =
DefaultStreamBufferSize } and pass buf or set r.options.BufferSize = buf),
referencing rawChannel, executor.ExecuteStreaming, r.options.BufferSize, and
DefaultStreamBufferSize.
- Around line 131-152: The template currently emits package-level symbols like
StreamedListObjectsChannel and convertToStreamedListObjectsChannel with a
hardcoded element type StreamedListObjectsResponse which will collide if
multiple operations use x-streaming; update the mustache generation to
parameterize these names and the channel element type from
vendorExtensions.x-streaming-response-type (and/or operation identifier) so each
streaming operation gets unique types/functions (e.g., derive Channel type name
and convert function name from the operationId or vendorExtensions key), replace
all occurrences of StreamedListObjectsResponse with the
vendorExtensions.x-streaming-response-type reference, and ensure Close/cancel
behavior remains the same; this removes global name conflicts and makes the
template reusable for multiple x-streaming operations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6b62607b-535a-4022-b51e-a9e6ebcab059
📒 Files selected for processing (8)
config/clients/go/config.overrides.jsonconfig/clients/go/template/CONTRIBUTING.md.mustacheconfig/clients/go/template/README_calling_other_endpoints.mustacheconfig/clients/go/template/api.mustacheconfig/clients/go/template/internal/constants.mustacheconfig/clients/go/template/streaming.mustacheconfig/clients/go/template/streaming_test.mustacheconfig/common/files/README.mustache
💤 Files with no reviewable changes (1)
- config/clients/go/template/streaming.mustache
…python
The shared README.mustache references {{>README_calling_other_endpoints}}
guarded by supportsCallingOtherEndpoints, but the partial only existed for go,
crashing java/python builds with TemplateNotFoundException. Add the partial for
both and remove the now-duplicate Calling Other Endpoints section that was
embedded in java's README_retries and python's README_calling_api.
Description
What problem is being solved?
How is it being solved?
What changes are made to solve it?
References
Review Checklist
mainSummary by CodeRabbit
New Features
Documentation
Chores