refactor: replace hardcoded user plan strings with CloudPlan enum - #27675
Conversation
Summary of ChangesHello @laipz8200, 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! This pull request refactors the backend codebase by replacing hardcoded user plan string literals with a new Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a solid refactoring that replaces hardcoded plan strings with a CloudPlan enum, significantly improving type safety and maintainability across the codebase. The changes are well-executed and consistent. I've added a couple of suggestions to further leverage the new enum for even better type safety in a Pydantic model and a request parser, which aligns with the goals of this PR.
1f5e56d to
e5cbf84
Compare
- Create CloudPlan StrEnum with SANDBOX, PROFESSIONAL, and TEAM values - Replace all hardcoded 'sandbox' strings with CloudPlan.SANDBOX throughout backend - Update 18 production files and 4 test files for consistency - Use auto() for automatic lowercase value generation from enum names Fixes #27674
e5cbf84 to
306edc0
Compare
Summary
This PR introduces a
CloudPlanStrEnum to replace hardcoded user plan string literals throughout the backend codebase, improving type safety and maintainability.Changes:
api/enums/cloud_plan.pywith CloudPlan enum (SANDBOX, PROFESSIONAL, TEAM)auto()for automatic lowercase value generationCloudPlan.SANDBOXin 18 production filesBenefits:
Fixes #27674
Screenshots
N/A - Backend refactoring only, no UI changes
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods