Skip to content

chore: reverse sync go-sdk#707

Merged
SoulPancake merged 5 commits into
mainfrom
chore/reverse-sync-go-sdk
Jun 19, 2026
Merged

chore: reverse sync go-sdk#707
SoulPancake merged 5 commits into
mainfrom
chore/reverse-sync-go-sdk

Conversation

@SoulPancake

@SoulPancake SoulPancake commented Jun 3, 2026

Copy link
Copy Markdown
Member

Description

What problem is being solved?

How is it being solved?

What changes are made to solve it?

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • New Features

    • Added streaming support for list operations in the Go SDK.
    • Added capability to call additional API endpoints not yet included in the SDK wrapper.
  • Documentation

    • Added contribution guidelines for the Go SDK.
    • Added guide for calling other endpoints via the API client.
  • Chores

    • Bumped Go SDK version to 0.8.1.
    • Updated user agent to reflect SDK version information.

Copilot AI review requested due to automatic review settings June 3, 2026 10:41
@SoulPancake SoulPancake requested a review from a team as a code owner June 3, 2026 10:41
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b2b2ab55-d5e4-4804-a569-156b86669803

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR adds streaming support for list operations to the Go SDK generator via conditional x-streaming handling in the API client template. It introduces version 0.8.1, adds configuration flags, provides complete contribution and API calling guides, and updates tests to validate streaming through the generated client API.

Changes

Go SDK streaming and documentation expansion

Layer / File(s) Summary
Configuration, version, and documentation setup
config/clients/go/config.overrides.json, config/clients/go/template/CONTRIBUTING.md.mustache, config/clients/go/template/README_calling_other_endpoints.mustache, config/common/files/README.mustache
SDK version bumped to 0.8.1; new supportsCallingOtherEndpoints and hideClientBatchCheckToc config flags enable streaming documentation. CONTRIBUTING.md template covers setup, editing guidance, testing/telemetry conventions, and API method procedures. README_calling_other_endpoints template documents APIExecutor usage for custom endpoints with Execute, ExecuteWithDecode, and ExecuteStreaming examples. README integration conditionally includes the new "Calling Other Endpoints" section.
Streaming API implementation in api.mustache
config/clients/go/template/api.mustache
Adds StreamingRequestOptions type and conditionally updates Execute method signatures when x-streaming is enabled. Streaming operations return *StreamedListObjectsChannel instead of decoded response. Implements StreamedListObjectsChannel with Objects and Errors channels plus Close() method. Service-level streaming Execute calls executor.ExecuteStreaming and converts raw channel output via JSON unmarshaling into typed StreamedListObjectsResponse values forwarded through the typed channel.
Streaming test implementation
config/clients/go/template/streaming_test.mustache
Renames streaming tests from *WithChannel* to *WithAPI* variants. Updates all tests to use the generated API client (OpenFgaApi.StreamedListObjects(...).Body(...).Execute()) instead of helper functions. Adds edge-case validation: TestProcessStreamingResponse_NilResponse and TestProcessStreamingResponse_NilBody verify error handling when given nil *http.Response or nil Body.
Supporting infrastructure and constants
config/clients/go/template/internal/constants.mustache, config/clients/go/template/streaming.mustache
UserAgent constant now builds from SDK name and SdkVersion at generation time. streaming.mustache template prepends partial_header before package declaration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • openfga/sdk-generator#666: Introduces the original streaming template utilities (streaming.mustache, streaming_test.mustache) and channel/streaming processing types that this PR extends with x-streaming vendor support and API client integration.
  • openfga/sdk-generator#660: Updates api.mustache to route operation execution through APIExecutor; this PR's streaming path now uses executor.ExecuteStreaming within that same execution flow.
  • openfga/sdk-generator#706: Also updates config/common/files/README.mustache to conditionally render documentation sections based on new generator feature flags (supportsCallingOtherEndpoints, hideClientBatchCheckToc).

Suggested reviewers

  • rhamzeh
  • sergiught
  • ewanharris
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'chore: reverse sync go-sdk' is vague and does not clearly describe the specific changes made in the pull request. Provide a more specific title that describes the main change, such as 'chore: add streaming support and contribute guide to Go SDK' or similar, to clarify the scope of changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/reverse-sync-go-sdk

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread config/clients/go/template/streaming.mustache Outdated
Comment thread config/clients/go/template/README_calling_other_endpoints.mustache

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
config/clients/go/template/api.mustache (2)

255-255: 💤 Low value

Streaming Execute() uses BufferSize: 0 when Options() is not called.

If a caller invokes .Body(...).Execute() without .Options(StreamingRequestOptions{...}), r.options.BufferSize is 0, producing an unbuffered raw channel and, downstream, an unbuffered Objects channel. The docs recommend DefaultStreamBufferSize. 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 tradeoff

Hardcoded StreamedListObjects* declarations make the Go streaming template non-reusable across multiple x-streaming operations

StreamedListObjectsChannel / convertToStreamedListObjectsChannel are emitted inside {{#operation}}{{#vendorExtensions.x-streaming}}, so if a second operation ever sets x-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 to StreamedListObjectsResponse (e.g., var response StreamedListObjectsResponse, Objects chan StreamedListObjectsResponse). Prefer deriving the response/channel element type from vendorExtensions.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

📥 Commits

Reviewing files that changed from the base of the PR and between 2639d35 and 71aa22d.

📒 Files selected for processing (8)
  • config/clients/go/config.overrides.json
  • config/clients/go/template/CONTRIBUTING.md.mustache
  • config/clients/go/template/README_calling_other_endpoints.mustache
  • config/clients/go/template/api.mustache
  • config/clients/go/template/internal/constants.mustache
  • config/clients/go/template/streaming.mustache
  • config/clients/go/template/streaming_test.mustache
  • config/common/files/README.mustache
💤 Files with no reviewable changes (1)
  • config/clients/go/template/streaming.mustache

Comment thread config/clients/go/template/README_calling_other_endpoints.mustache
@SoulPancake SoulPancake marked this pull request as draft June 3, 2026 11:30
@SoulPancake SoulPancake marked this pull request as ready for review June 18, 2026 14:22
…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.
@SoulPancake SoulPancake enabled auto-merge June 19, 2026 01:33
@SoulPancake SoulPancake added this pull request to the merge queue Jun 19, 2026
Merged via the queue into main with commit 5854aa1 Jun 19, 2026
13 of 15 checks passed
@SoulPancake SoulPancake deleted the chore/reverse-sync-go-sdk branch June 19, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants