chore: release versions#614
Conversation
There was a problem hiding this comment.
Code Review
This pull request extracts core modules into a new google-workspace library crate, enabling programmatic Rust API access, and updates the project version to 0.21.0. A critical issue was identified in the new client module's retry logic, where the final error might be incorrectly discarded, making debugging difficult. A refactoring suggestion has been provided to ensure the most relevant error is always returned.
There was a problem hiding this comment.
The retry logic in the new client module has a flaw that could mask the true cause of persistent failures. In crates/google-workspace/src/client.rs, the send_with_retry function incorrectly prioritizes a previous transient error over the error from the final retry attempt.
Specifically, on line 80, Err(last_err.unwrap_or(e)) will return last_err if it exists, discarding the more relevant final error e. This makes debugging difficult.
I recommend refactoring the function to remove the last_err variable and ensure the error from the very last attempt is always returned. Here is a suggested implementation:
pub async fn send_with_retry(
build_request: impl Fn() -> reqwest::RequestBuilder,
) -> Result<reqwest::Response, reqwest::Error> {
for attempt in 0..MAX_RETRIES {
match build_request().send().await {
Ok(resp) => {
if resp.status() != reqwest::StatusCode::TOO_MANY_REQUESTS {
return Ok(resp);
}
let header_value = resp
.headers()
.get("retry-after")
.and_then(|v| v.to_str().ok());
let retry_after = compute_retry_delay(header_value, attempt);
tokio::time::sleep(std::time::Duration::from_secs(retry_after)).await;
}
Err(e) if e.is_connect() || e.is_timeout() => {
let delay = compute_retry_delay(None, attempt);
tokio::time::sleep(std::time::Duration::from_secs(delay)).await;
}
Err(e) => return Err(e), // Non-retryable error
}
}
// Final attempt
build_request().send().await
}
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@googleworkspace/cli@0.21.0
Minor Changes
029e5de: Extract
google-workspacelibrary crate for programmatic Rust API access (closes feat: expose minimal library crate for programmatic API access #386)Introduces a Cargo workspace with a new
google-workspacelibrary crate (crates/google-workspace/)that exposes the core modules for use as a Rust dependency:
discovery— Discovery Document types and fetchingerror— StructuredGwsErrortypeservices— Service registry and resolutionvalidate— Input validation and URL encodingclient— HTTP client with retry logicThe
gwsbinary crate re-exports all library types transparently — zero behavioral changes.