fix: increase project timeout and add manual entry in gws auth setup (closes #116)#233
fix: increase project timeout and add manual entry in gws auth setup (closes #116)#233NeekChaw wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
…loses googleworkspace#116) Users who belong to organizations with thousands of GCP projects would hit the hardcoded 10-second timeout in gws auth setup when the CLI attempted to list their projects, blocking them from completing setup without manually using --project. This PR improves the experience for these users by: 1. Increasing the project listing timeout from 10s to 30s 2. Adding a new '✏️ Enter existing project ID' option to the interactive project picker.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
🦋 Changeset detectedLatest commit: d66f087 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, 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 significantly improves the Highlights
Changelog
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 increases the project listing timeout and adds an option to manually enter a project ID. My review focuses on improving maintainability. I've suggested defining the timeout value as a constant to avoid inconsistencies, and refactoring some duplicated logic that was expanded in this PR. Addressing these points would make the code easier to manage in the future.
| return ( | ||
| Vec::new(), | ||
| Some("Timed out listing projects (10s)".to_string()), | ||
| Some("Timed out listing projects (30s)".to_string()), |
There was a problem hiding this comment.
The timeout value 30 is hardcoded here. It's also hardcoded on line 549 where the duration is set. This can lead to inconsistencies if the value is changed in one place but not the other. It would be better to define a constant for the timeout and use it to format this message.
For example:
// At the top of `list_gcloud_projects`
const LIST_PROJECTS_TIMEOUT_SECS: u64 = 30;
// ... in the function
let timeout = std::time::Duration::from_secs(LIST_PROJECTS_TIMEOUT_SECS);
// ... later in the function
return (
Vec::new(),
Some(format!("Timed out listing projects ({}s)", LIST_PROJECTS_TIMEOUT_SECS)),
);| Some(item) if item.label.starts_with("✏️") => { | ||
| let project_id = match ctx | ||
| .wizard | ||
| .as_mut() | ||
| .unwrap() | ||
| .show_input("Enter GCP project", "Enter an existing project ID", None) | ||
| .map_err(|e| GwsError::Validation(format!("TUI error: {e}")))? | ||
| { | ||
| crate::setup_tui::InputResult::Confirmed(v) if !v.is_empty() => v, | ||
| _ => { | ||
| return Err(GwsError::Validation( | ||
| "Project selection cancelled by user".to_string(), | ||
| )) | ||
| } | ||
| }; | ||
|
|
||
| set_gcloud_project(&project_id)?; | ||
| ctx.wiz(2, StepStatus::Done(project_id.clone())); | ||
| ctx.project_id = project_id; | ||
| Ok(SetupStage::EnableApis) | ||
| } |
There was a problem hiding this comment.
This new logic for manually entering a project ID introduces some code duplication that's also present in other arms of this match statement. To improve maintainability, consider a couple of refactorings:
-
The logic for getting user input (lines 1036-1049) is very similar to the logic for getting a new project name (lines 1057-1070). This could be extracted into a helper function.
-
The final block of code (lines 1051-1054) that sets the project and advances the stage is identical to the logic in the other
matcharms. This could be moved outside thematchstatement to run after theproject_idhas been determined.
Applying these refactorings would make the code more DRY and easier to maintain in the future.
|
Closing this PR - the same fix (30s timeout + manual project ID entry) has already been merged into |
Closes #116
…(closes #116)
Users who belong to organizations with thousands of GCP projects would hit the hardcoded 10-second timeout in gws auth setup when the CLI attempted to list their projects, blocking them from completing setup without manually using --project.
This PR improves the experience for these users by:
Description
Please include a summary of the change and which issue is fixed. If adding a new feature or command, please include the output of running it with
--dry-runto prove the JSON request body matches the Discovery Document schema.Dry Run Output:
// Paste --dry-run output here if applicableChecklist:
AGENTS.mdguidelines (no generatedgoogle-*crates).cargo fmt --allto format the code perfectly.cargo clippy -- -D warningsand resolved all warnings.pnpx changeset) to document my changes.