Skip to content

fix: lint fixes, sync with generator, use common streaming interface for streamed list objects#259

Merged
SoulPancake merged 7 commits intomainfrom
fix/lintfix-sync-with-generator
Nov 25, 2025
Merged

fix: lint fixes, sync with generator, use common streaming interface for streamed list objects#259
SoulPancake merged 7 commits intomainfrom
fix/lintfix-sync-with-generator

Conversation

@SoulPancake
Copy link
Copy Markdown
Member

@SoulPancake SoulPancake commented Nov 19, 2025

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

  • Bug Fixes

    • Improved error handling in streaming responses to properly surface resource cleanup errors via error channel.
  • Documentation

    • Enhanced API documentation with expanded details and restructured examples.
  • Style

    • Code formatting and whitespace consistency improvements.
  • Tests

    • Updated test cases for improved error handling practices.

Copilot AI review requested due to automatic review settings November 19, 2025 17:16
@SoulPancake SoulPancake requested a review from a team as a code owner November 19, 2025 17:16
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 19, 2025

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.

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

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The PR applies formatting and whitespace refinements to the API client, augments documentation comments in the OpenFGA interface, and modifies error handling in streaming response processing to capture and propagate HTTP response body close errors through a channel rather than silently ignoring them. Test files are updated to explicitly suppress write error returns.

Changes

Cohort / File(s) Summary
Formatting & Documentation
api_client.go, api_open_fga.go
Consistent indentation, whitespace adjustments, and documentation comment reflowing across internal helpers and interface definitions. No public API signature or core logic changes.
Streaming Error Handling
streaming.go
Refactors resource cleanup in ProcessStreamedListObjectsResponse to surface HTTP response body close errors via the channel instead of silently discarding them. All other scanning, buffering, and error propagation logic preserved.
Test Error Suppression
client/streaming_test.go, streaming_test.go
Replaces direct HTTP response writer calls with blank identifier assignments to explicitly ignore write error returns across eight streaming test cases. Response contents and test control flow remain functionally unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant ProcessStreamedListObjectsResponse
    participant HTTPResponse
    participant Channel
    
    Caller->>ProcessStreamedListObjectsResponse: Call function
    ProcessStreamedListObjectsResponse->>HTTPResponse: Begin reading body
    
    note over ProcessStreamedListObjectsResponse: Defer: Close body & handle error
    
    loop Process stream
        ProcessStreamedListObjectsResponse->>HTTPResponse: Read line
        HTTPResponse-->>ProcessStreamedListObjectsResponse: Data/EOF
        ProcessStreamedListObjectsResponse->>Channel: Send result
    end
    
    ProcessStreamedListObjectsResponse->>HTTPResponse: Close body (deferred)
    alt Close succeeds
        HTTPResponse-->>ProcessStreamedListObjectsResponse: nil
    else Close fails
        HTTPResponse-->>ProcessStreamedListObjectsResponse: error
        ProcessStreamedListObjectsResponse->>Channel: Send error
    end
    
    Channel-->>Caller: Results + potential close error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • streaming.go: The deferred error handling modification for HTTP response body closure requires verification that error propagation through the channel doesn't introduce race conditions or interfere with existing error handling patterns.
  • streaming_test.go & client/streaming_test.go: Eight test modifications suppressing write errors need careful inspection to confirm the suppression is intentional and doesn't mask actual issues; verify test assertions still validate expected behavior.
  • api_client.go & api_open_fga.go: Formatting changes are straightforward but should be spot-checked for accidental logic alterations given the volume of whitespace adjustments.

Suggested reviewers

  • ewanharris
  • sergiught

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.74% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: lint fixes, synchronization with the generator, and implementation of a common streaming interface for streamed list objects.

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.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 45.79125% with 161 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.89%. Comparing base (c52ca06) to head (9b7706f).

Files with missing lines Patch % Lines
api_client.go 42.29% 121 Missing and 25 partials ⚠️
streaming.go 65.90% 12 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #259      +/-   ##
==========================================
+ Coverage   33.82%   33.89%   +0.07%     
==========================================
  Files         114      114              
  Lines       10990    11022      +32     
==========================================
+ Hits         3717     3736      +19     
- Misses       6911     6922      +11     
- Partials      362      364       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR applies lint fixes and syncs code formatting with the OpenAPI generator for streamed list objects functionality.

Key changes:

  • Adds proper error handling for deferred Body.Close() in streaming response processing
  • Fixes Go linter warnings by handling return values from w.Write() calls in test files
  • Normalizes code indentation from spaces to tabs across multiple files for consistency

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
streaming.go Added error handling for deferred Body.Close() in streaming response processor
streaming_test.go Fixed linter warnings by capturing w.Write() return values in test handlers
client/streaming_test.go Fixed linter warnings by capturing w.Write() return values in test handlers
api_open_fga.go Normalized indentation from spaces to tabs in API documentation comments
api_client.go Normalized indentation from spaces to tabs throughout the file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3d3a23 and dc277ee.

📒 Files selected for processing (5)
  • api_client.go (1 hunks)
  • api_open_fga.go (13 hunks)
  • client/streaming_test.go (5 hunks)
  • streaming.go (1 hunks)
  • streaming_test.go (8 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
api_client.go (9)
configuration.go (2)
  • Configuration (22-37)
  • RetryParams (19-19)
telemetry/configuration.go (2)
  • Configuration (32-34)
  • DefaultTelemetryConfiguration (36-83)
internal/utils/retryutils/retryparams.go (2)
  • RetryParams (6-9)
  • GetRetryParamsOrDefault (29-35)
telemetry/telemetry.go (4)
  • Telemetry (16-19)
  • Bind (87-89)
  • Get (65-85)
  • TelemetryFactoryParameters (21-23)
credentials/credentials.go (1)
  • Credentials (38-42)
errors.go (5)
  • NewFgaApiValidationError (335-365)
  • NewFgaApiNotFoundError (451-481)
  • NewFgaApiRateLimitExceededError (755-809)
  • NewFgaApiInternalError (593-629)
  • NewFgaApiError (219-249)
model_validation_error_message_response.go (1)
  • ValidationErrorMessageResponse (22-25)
model_path_unknown_error_message_response.go (1)
  • PathUnknownErrorMessageResponse (22-25)
model_internal_error_message_response.go (1)
  • InternalErrorMessageResponse (22-25)
🪛 Gitleaks (8.29.0)
api_open_fga.go

[high] 553-553: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 581-581: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 615-615: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 723-723: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: CodeQL analysis (go)
  • GitHub Check: Agent
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
client/streaming_test.go (1)

43-43: LGTM - Explicit error suppression in tests.

Using _, _ = w.Write() appropriately documents that write errors are intentionally ignored in these test HTTP handlers. This is a common and acceptable pattern in Go tests with httptest.ResponseWriter.

Also applies to: 101-101, 149-149, 216-216, 283-283

api_open_fga.go (1)

42-912: LGTM - Documentation improvements.

All changes are documentation-only refinements (formatting, expanded examples, added reference sections). No functional code changes.

streaming_test.go (1)

60-60: LGTM - Explicit error suppression in tests.

Using _, _ = w.Write() appropriately documents that write errors are intentionally ignored in test HTTP handlers, consistent with standard Go test patterns.

Also applies to: 118-118, 163-163, 217-217, 265-265, 329-329, 389-389, 440-440

api_client.go (1)

4-499: LGTM - Formatting refinements.

All changes are formatting and whitespace adjustments with no behavioral modifications. These align with standard Go formatting conventions.

@SoulPancake SoulPancake changed the title fix: lint fixes, sync with generator for streamed list objects fix: lint fixes, sync with generator, use common streaming interface for streamed list objects Nov 20, 2025
Copy link
Copy Markdown
Member

@ewanharris ewanharris left a comment

Choose a reason for hiding this comment

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

Fine for separate PR, but maybe we could add a lint/format check within the existing workflow? I guess we never really had it til now because everything would always be linted/formatted by the sdk-generator process

@SoulPancake
Copy link
Copy Markdown
Member Author

SoulPancake commented Nov 25, 2025

Fine for separate PR, but maybe we could add a lint/format check within the existing workflow? I guess we never really had it til now because everything would always be linted/formatted by the sdk-generator process

Sure, I'll add a follow up PR immediately after this

@SoulPancake SoulPancake added this pull request to the merge queue Nov 25, 2025
Merged via the queue into main with commit 2258969 Nov 25, 2025
15 checks passed
@SoulPancake SoulPancake deleted the fix/lintfix-sync-with-generator branch November 25, 2025 14:16
@dosubot
Copy link
Copy Markdown

dosubot bot commented Nov 25, 2025

Related Documentation

Checked 6 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

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.

5 participants