Skip to content

fix: google sheets timeout issue #6132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

utsabc
Copy link
Member

@utsabc utsabc commented Jul 17, 2025

Description

The error "CDM GOOGLESHEETS Unable to create client for context deadline exceeded" was caused by several timeout-related issues in the Google Sheets client creation process:

Issues Fixed:
Missing Timeout Context in Service Creation: The generateService function was using context.Background() without any timeout when creating the Google Sheets service.

Missing Timeout Context in OAuth Token Retrieval: The generateOAuthClient function was also using context.Background() without timeout when retrieving OAuth tokens.

No Timeout Propagation: The timeout value from the custom destination manager wasn't being properly propagated through the Google Sheets client creation chain.

Changes Made:
Updated generateService to accept a timeout parameter and use context.WithTimeout()
Updated generateOAuthClient to accept a timeout parameter and use context.WithTimeout()
Updated clientOptions to accept and pass through the timeout parameter
Added time import to support timeout functionality
Updated call sites to pass the timeout value through the chain

Linear Ticket

https://linear.app/rudderstack/issue/INT-3950/google-sheet-investigate-1542-failed-events-on-facebook-feed-in

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@utsabc utsabc requested review from Copilot, atzoum and cisse21 July 17, 2025 12:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses timeout issues in the Google Sheets client by propagating a configurable timeout through service creation and OAuth token retrieval.

  • Added a timeout parameter to clientOptions, generateService, and generateOAuthClient
  • Updated call sites in NewProducer to pass the timeout value
  • Imported the time package and used context.WithTimeout to enforce deadlines
Comments suppressed due to low confidence (3)

services/streammanager/googlesheets/googlesheetsmanager.go:147

  • [nitpick] Update this comment to reflect the added timeout parameter, e.g., indicate that generateService accepts a timeout and applies it to the context.
// generateService produces a google-sheets client using the specified client options

services/streammanager/googlesheets/googlesheetsmanager.go:325

  • [nitpick] Update this comment to mention the timeout argument in generateOAuthClient's signature so the contract is clear.
// generateOAuthClient produces an OAuth client based on a jwt Config

services/streammanager/googlesheets/googlesheetsmanager.go:295

  • Add unit tests to verify that the timeout parameter is properly applied in clientOptions, generateOAuthClient, and generateService, ensuring deadlines are enforced when contexts expire.
func clientOptions(config *Config, timeout time.Duration) ([]option.ClientOption, error) {

ctx := context.Background()
func generateOAuthClient(jwtconfig *jwt.Config, timeout time.Duration) (*http.Client, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
var oauthconfig *oauth2.Config
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

The variable oauthconfig is declared but never initialized before use, leading to a nil pointer dereference when calling oauthconfig.Client. Initialize oauthconfig properly or use jwtconfig.Client directly.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

@manish339k Can you verify this too

Copy link

codecov bot commented Jul 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.70%. Comparing base (c97ad7a) to head (be9f9a9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6132      +/-   ##
==========================================
- Coverage   76.77%   76.70%   -0.07%     
==========================================
  Files         521      521              
  Lines       70779    70781       +2     
==========================================
- Hits        54340    54294      -46     
- Misses      13548    13594      +46     
- Partials     2891     2893       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@manish339k manish339k force-pushed the fix.google-sheets-timeout-issue-2 branch 2 times, most recently from 7d55dd6 to 10efc6d Compare July 23, 2025 02:58
Copy link

This PR is considered to be stale. It has been open 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR.

@github-actions github-actions bot added the Stale label Aug 13, 2025
@manish339k manish339k force-pushed the fix.google-sheets-timeout-issue-2 branch from 10efc6d to be9f9a9 Compare August 18, 2025 04:18
@manish339k manish339k removed the Stale label Aug 18, 2025
@manish339k manish339k requested a review from koladilip August 18, 2025 04:19
@manish339k manish339k requested a review from vinayteki95 August 19, 2025 05:02
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.

4 participants