Skip to content

Conversation

justinsheu
Copy link
Collaborator

📝 Summary

Now return API Key and org ID for root user when created
Root user creation flow is now the following

🎯 Purpose

If account doesn't exist, create it and return user id
If account exists, return user id
If account exists but isn't a root account, prompt user to run command again with different creds

🎥 Demo of Changes

N/A

🧪 Testing

Tested with test Supabase account

✅ Checklist

  • Self-review
  • Video demo of changes
  • Unit Tests and CI/CD tests are passing
  • Reviewers assigned

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @justinsheu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request focuses on improving the root user creation flow and ensuring that the API key and organization ID are returned upon successful creation. It modifies the cli.py file to disable pretty exceptions in Typer, and significantly updates the supabase.py file to handle existing root user scenarios, prevent non-root users from using root-only functionality, and retrieve the API key and organization ID after user creation.

Highlights

  • Root User Creation Flow: The root user creation process now checks for existing users with matching credentials before attempting to create a new user. If a user exists but isn't a root user, an error is raised, prompting the user to use different credentials.
  • API Key and Organization ID Retrieval: The code now retrieves and returns the API key and organization ID for the root user immediately after creation, ensuring that these values are readily available.
  • Error Handling: A new NonRootUserError exception is introduced to handle cases where a non-root user attempts to use root-only functionality, improving error reporting and preventing unintended actions.

Changelog

  • judgment/cli.py
    • Disabled pretty exceptions in Typer to provide more detailed error messages.
  • judgment/self_host/supabase/supabase.py
    • Added NonRootUserError exception for handling non-root user access attempts.
    • Modified create_root_user to check for existing root users and handle non-root user scenarios.
    • Implemented get_user_api_key_and_org to retrieve the API key and organization ID for a given user ID.
    • Improved documentation and error handling for root user creation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A root user's key,
Unlocks secrets, you see.
Org's ID held tight,
Guiding code through the night,
Judgment's power, finally free.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request improves the root user creation flow and returns the API key and organization ID for the root user. The changes seem well-structured and address the intended purpose. However, there are a few areas that could be improved for clarity and error handling.

Summary of Findings

  • Error Handling in create_root_user: The create_root_user function catches a generic Exception during sign-in, which might mask specific errors. It's better to catch more specific exceptions to handle them appropriately and provide more informative error messages.
  • Missing Return Values in create_root_user: The create_root_user function does not explicitly return a value in all execution paths, which can lead to unexpected behavior. Ensure that all possible execution paths return a value or raise an exception.
  • Clarity of Error Messages: Some error messages could be more descriptive to help users understand the root cause of the problem and how to resolve it.

Merge Readiness

The pull request is almost ready for merging, but there are a few issues that need to be addressed. Specifically, the error handling in create_root_user should be improved, and all execution paths should return a value. I am unable to approve this pull request, and recommend that these issues be addressed before merging. It is also recommended that others review and approve this code before merging.

@JCamyre JCamyre self-requested a review June 11, 2025 19:42
Copy link
Contributor

@JCamyre JCamyre left a comment

Choose a reason for hiding this comment

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

LGTM! One quick question

except Exception as e:
typer.echo(f"Error during deployment: {str(e)}", err=True)
raise typer.Exit(1)
deploy(creds, supabase_compute_size, root_judgment_email, root_judgment_password, domain_name, invitation_email_service)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you remove try except because it raises typer.Exit exception in deploy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I think it was because this try except was redundant and the actual exception becomes a generic typer.Exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants