I encountered an issue while using the Ingress Field Planner tool where the code breaks if a new solution has the same name as a previous one. This happens when the code tries to create a new sheet in Google Sheets with the same name as an existing one, which is not allowed.
Steps to reproduce:
Run the code and get some results.
Stop the code before it finishes all iterations.
Run the code again.
If the new solution has the same name as the previous one, the code will break with the following error message:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/[SPREADSHEET_ID]:batchUpdate?alt=json returned "Invalid requests[0].addSheet: A sheet with the name "[SHEET_NAME]" already exists. Please enter another name.". Details: "Invalid requests[0].addSheet: A sheet with the name "[SHEET_NAME]" already exists. Please enter another name.">
Expected behavior:
The code should either overwrite the existing sheet with the new solution or append a unique identifier to the sheet name to avoid naming conflicts.
Suggested fix:
Before creating a new sheet, the code should check if a sheet with the same name already exists. If it does, the code could either:
Overwrite the existing sheet with the new solution, or
Append a unique identifier (such as a timestamp or random number) to the sheet name to avoid naming conflicts.
I encountered an issue while using the Ingress Field Planner tool where the code breaks if a new solution has the same name as a previous one. This happens when the code tries to create a new sheet in Google Sheets with the same name as an existing one, which is not allowed.
Steps to reproduce:
Expected behavior:
The code should either overwrite the existing sheet with the new solution or append a unique identifier to the sheet name to avoid naming conflicts.
Suggested fix:
Before creating a new sheet, the code should check if a sheet with the same name already exists. If it does, the code could either: