Skip to content

Conversation

Siddhant-K-code
Copy link
Member

@Siddhant-K-code Siddhant-K-code commented Aug 13, 2025

Description

What problem is being solved?

The fga query list-objects, fga query list-users, and fga query list-relations commands display confusing duplicate error messages like:

Error: failed to list objects due to failed to list objects due to [actual error]

This makes error messages hard to read and understand for users.

How is it being solved?

By fixing the error handling pattern to match other commands in the codebase:

  • Internal functions wrap errors with context (e.g., "failed to list objects due to")
  • Command functions return errors directly without additional wrapping

What changes are made to solve it?

Modified three files to remove duplicate error wrapping:

  • cmd/query/list-objects.go - Remove duplicate wrapping in RunE function
  • cmd/query/list-users.go - Remove duplicate wrapping in RunE function
  • cmd/query/list-relations.go - Remove duplicate wrapping in RunE function

Result: Clean error messages like Error: failed to list objects due to [actual error]

References

fixes #556

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • 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

  • Refactor

    • Streamlined error handling for listing objects, relations, and users in the CLI, returning raw errors for clearer diagnostics.
    • Preserves existing command behavior and outputs on success; no changes to public interfaces.
  • User Experience

    • Improved clarity of error messages when listing objects, relations, or users.

Signed-off-by: Siddhant Khare <Siddhantkhare2694@gmail.com>
@Siddhant-K-code Siddhant-K-code requested a review from a team as a code owner August 13, 2025 04:21
Copy link
Contributor

coderabbitai bot commented Aug 13, 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.

Walkthrough

Error handling was adjusted in three query CLI commands to return raw errors instead of wrapping them with additional context. No public APIs or control flows were changed.

Changes

Cohort / File(s) Summary
Query CLI error handling
cmd/query/list-objects.go, cmd/query/list-relations.go, cmd/query/list-users.go
Replaced fmt.Errorf wrapping with returning original errors. In list-relations, applied to internal calls and RunE path; in list-objects and list-users, applied in primary error paths. No signature or flow changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix duplicate error output in CLI (#556) Raw-error returns may reduce duplication, but without observing CLI error aggregation/printing behavior, it’s unclear if duplicates are fully resolved.
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rhamzeh rhamzeh changed the title Fix duplicate error messages in query commands fix: duplicate error messages in query commands Aug 13, 2025
Copy link
Member

@rhamzeh rhamzeh left a comment

Choose a reason for hiding this comment

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

Thanks @Siddhant-K-code! This looks good!

Can I ask you to add a note in the CHANGELOG.md file under unreleased? We're trying to follow that to make it easier when we end up releasing a new version.

This is only needed for non-chore changes

Later we'll copy this workflow from openfga/openfga so that it errors and we don't have to manually verify

@Siddhant-K-code
Copy link
Member Author

@rhamzeh done, we are good to go :)

@rhamzeh rhamzeh added this pull request to the merge queue Aug 13, 2025
Merged via the queue into openfga:main with commit 77c7c46 Aug 13, 2025
19 checks passed
@Siddhant-K-code Siddhant-K-code deleted the fix/remove-duplicate-error-messages branch August 13, 2025 16:57
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.

Fix error output to not have duplicate message
2 participants