HttpError returned by Google Sheets#953
Merged
Merged
Conversation
ebattat
reviewed
Nov 24, 2025
| if sheet['properties']['title'] == sheet_name: | ||
| return sheet['properties']['sheetId'] | ||
| return '' | ||
| return None |
Member
There was a problem hiding this comment.
can we retrun None instread of string, is it ok when using this method ?
Member
Author
There was a problem hiding this comment.
reverted the 'return None' change as it may disturb other api's. Instead added another check in create_work_sheet() to check for '', so sheet id 0 is not evaluated to True
Member
Author
There was a problem hiding this comment.
Tested the new changes locally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Note: Fill x in []
Description
Getting a 400 Http Error in Jenkins :
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/****:batchUpdate?alt=json returned "Invalid requests[0].addSheet: A sheet with the name "PERF-DEPT" already exists. Please enter another name.". Details: "Invalid requests[0].addSheet: A sheet with the name "PERF-DEPT" already exists. Please enter another name.">
PERF-DEPT is the first sheet in the Cloud Tags workbook with id 0, which is causing script to try to create a new worksheet (because of how Python treats the integer 0).
FIX: Modified the code to handle return value differently, so sheet id 0 does not lead to creating a new sheet (if block).
For security reasons, all pull requests need to be approved first before running any automated CI