Skip to content

Add Gemini code-execution artifact support and tests (WiP)#86

Open
Benjamin-Sayaque wants to merge 13 commits into
mainfrom
codex/add-code-execution-tool-to-payload-builder
Open

Add Gemini code-execution artifact support and tests (WiP)#86
Benjamin-Sayaque wants to merge 13 commits into
mainfrom
codex/add-code-execution-tool-to-payload-builder

Conversation

@Benjamin-Sayaque

Copy link
Copy Markdown
Contributor

Motivation

  • Support code execution for Gemini models, which return inline base64 artifacts rather than OpenAI code-interpreter container files.
  • Make enableCodeInterpreter provider-aware by documenting container reuse for OpenAI and ignoring container IDs for Gemini.
  • Provide automated tests to validate Gemini code execution and artifact downloading behavior.

Description

  • Updated enableCodeInterpreter to return this and clarified that the optional containerId is only applicable to OpenAI containers.
  • Added _extractGeminiInlineArtifacts to parse Gemini responses and collect inline base64 artifacts with inferred filenames and MIME types, and integrated it in the run flow for Gemini models.
  • Updated file metadata and download logic by documenting provider-specific return shapes in getGeneratedFiles, extending downloadGeneratedFile to accept filename lookups and to decode base64 data artifacts into blobs, and changed getContainerId to return null for Gemini models.
  • Extended _buildGeminiPayload to include a code_execution tool when code execution is enabled for Gemini, and retained existing OpenAI container download behavior.
  • Added test helpers and two Gemini-focused tests (testGeminiCodeExecution and testGeminiCodeExecutionWithArtifact) and registered them in testAll().

Testing

  • Ran the automated test suite via testAll() which includes the new Gemini tests, and the suite completed successfully.
  • Existing OpenAI code-interpreter tests remain conditional on Drive file IDs and were not executed in this run when Drive IDs were not provided.
  • New test helpers assertGeminiArtifactMetadata and assertBlobLike are used by the Gemini tests to validate artifact metadata and blob decoding.

Codex Task

@aubrypaul aubrypaul changed the title Add Gemini code-execution artifact support and tests Add Gemini code-execution artifact support and tests (WiP) Jun 9, 2026
@aubrypaul aubrypaul linked an issue Jun 9, 2026 that may be closed by this pull request

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d62bf24607

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/code.gs
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Gemini code-execution responses now yield inline base64 artifacts extracted into _generatedFiles; spreadsheet uploads are marked for lazy CSV conversion resolved at payload build time for both OpenAI and Gemini; generated-file retrieval/download behavior and test harness model/config are updated.

Changes

Gemini Code Interpreter Artifacts & Spreadsheet Conversion

Layer / File(s) Summary
Chat.addFile() lazy spreadsheet handling
src/code.gs
Chat.addFile() records _sourceFileId or _sourceBlob and pushes _needsSpreadsheetConversion placeholders for spreadsheet MIME types instead of immediate base64 encoding; non-spreadsheet files are embedded immediately.
OpenAI payload resolution
src/code.gs
_buildOpenAIPayload() resolves lazy spreadsheet parts at payload build time by converting referenced spreadsheet sources into CSV, performing size checks, and embedding as OpenAI input_file content.
Gemini payload building & conditional tooling
src/code.gs
_buildGeminiPayload() performs lazy spreadsheet-to-CSV conversion at request time (CSV preamble/formatting, size/cell checks), replaces placeholders with Gemini inline_data, and appends the code_execution tool only when code interpreter is enabled.
Gemini inline artifact extraction & download handling
src/code.gs
Adds _extractGeminiInlineArtifacts() to walk Gemini response parts and collect inline base64 artifacts; Chat.run() collects Gemini inline artifacts into _generatedFiles; downloadGeneratedFile() resolves by index/fileId/filename, decodes Gemini inline data to a Blob when applicable, and getContainerId() returns null for Gemini.
Drive MIME handling & spreadsheet utilities
src/code.gs
Adds _isSpreadsheetMimeType(), extends _getBlobFromGoogleDrive() to treat extra spreadsheet MIME types as convertible, and implements XLSX→CSV conversion, Google Sheets export to concatenated CSV (skipping hidden/empty sheets), RFC4180 CSV escaping/serialization, CSV preambles with sheet metadata, and size/cell-limit enforcement.
Configurable timeout
src/code.gs
Adds TIMEOUT_SECONDS from script properties and uses it to set _callGenAIApi() timeout instead of a fixed value.
enableCodeInterpreter docs
src/code.gs
JSDoc updated to describe provider-specific containerId semantics and small surrounding structural changes.
Test harness updates
src/testFunctions.gs
Updates GEMINI_MODEL, adjusts runTestAcrossModels() to set both Gemini and OpenAI keys and include generated-file logging, and refactors Code Interpreter Excel/PDF tests to run across models via the test harness.

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main changes: adding Gemini code-execution artifact support and associated tests, which aligns with the substantial file modifications summarized.
Description check ✅ Passed The description is directly related to the changeset, providing detailed motivation, implementation steps, and testing results that correspond to the code modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/add-code-execution-tool-to-payload-builder
  • 🛠️ JSDoc Checks

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/code.gs (1)

965-970: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing else causes empty string input to fail.

Line 965 uses if instead of else if. When an empty string is passed:

  1. Lines 962-964 correctly set targetFile to _generatedFiles[0]
  2. Line 968's else if (typeof "" === "string") then executes and overwrites targetFile with the find() result (which will be undefined since no file matches an empty string)

This causes the subsequent check at line 971 to throw an error instead of returning the first file.

🐛 Proposed fix
         if (fileIdOrIndex === undefined || fileIdOrIndex === null) {
           targetFile = this._generatedFiles[0];
         }
         else if (typeof fileIdOrIndex === "string" && fileIdOrIndex.trim() === "") {
           targetFile = this._generatedFiles[0];
         }
-        if (typeof fileIdOrIndex === "number") {
+        else if (typeof fileIdOrIndex === "number") {
           targetFile = this._generatedFiles[fileIdOrIndex];
         }
         else if (typeof fileIdOrIndex === "string") {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/code.gs` around lines 965 - 970, The branch that overwrites targetFile
when fileIdOrIndex is an empty string should skip empty-string inputs; update
the string branch condition (the clause that currently reads else if (typeof
fileIdOrIndex === "string")) to require a non-empty string (for example: else if
(typeof fileIdOrIndex === "string" && fileIdOrIndex !== "") ) so that when
fileIdOrIndex is "" the previously-set targetFile (e.g., _generatedFiles[0]) is
not overwritten; touch the logic around the variable fileIdOrIndex and the
assignment to targetFile in this block to ensure the subsequent existence check
works correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/code.gs`:
- Around line 900-904: The artifact extraction loop using parts.forEach only
reads part.inlineData, so if Gemini returns snake_case inline_data those
artifacts are skipped; update the parts.forEach callback to normalize or
fallback to both shapes (e.g., const inlineData = part?.inlineData ||
part?.inline_data) and then use inlineData and inputInlineData as before; ensure
this mirrors the logic used in the collectInputInlineData helper to handle both
inlineData and inline_data consistently.

---

Outside diff comments:
In `@src/code.gs`:
- Around line 965-970: The branch that overwrites targetFile when fileIdOrIndex
is an empty string should skip empty-string inputs; update the string branch
condition (the clause that currently reads else if (typeof fileIdOrIndex ===
"string")) to require a non-empty string (for example: else if (typeof
fileIdOrIndex === "string" && fileIdOrIndex !== "") ) so that when fileIdOrIndex
is "" the previously-set targetFile (e.g., _generatedFiles[0]) is not
overwritten; touch the logic around the variable fileIdOrIndex and the
assignment to targetFile in this block to ensure the subsequent existence check
works correctly.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 629f0f05-9204-405c-84c6-e67b85e1aef1

📥 Commits

Reviewing files that changed from the base of the PR and between 052e376 and d62bf24.

📒 Files selected for processing (2)
  • src/code.gs
  • src/testFunctions.gs
📜 Review details
🔇 Additional comments (9)
src/code.gs (5)

305-326: LGTM!


555-572: LGTM!


930-939: LGTM!


981-994: LGTM!


1062-1066: LGTM!

src/testFunctions.gs (4)

18-19: LGTM!


189-216: LGTM!


218-252: LGTM!


254-264: LGTM!

Comment thread src/code.gs
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • src/code.gs

Commit: 2aa70968f4481cb9521fd09faa082cc442cc8b1f

The changes have been pushed to the codex/add-code-execution-tool-to-payload-builder branch.

Time taken: 1m 10s

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/code.gs (2)

555-557: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Preserve Gemini artifacts across internal reruns.

When Gemini uses both code execution and user-defined functions, this branch captures artifacts from the current response, but the recursive this.run() at Lines 669-674 re-enters Line 469 and clears _generatedFiles before the next turn. Since _buildGeminiPayload() can send both functionDeclarations and code_execution, getGeneratedFiles() ends up keeping only the last loop's artifacts for that supported combination.

💡 Proposed fix
-          if (advancedParametersObject) {
-            return this.run(advancedParametersObject);
-          }
-          else {
-            return this.run();
-          }
+          const currentGeneratedFiles = this._generatedFiles.slice();
+          const result = advancedParametersObject ? this.run(advancedParametersObject) : this.run();
+          this._generatedFiles = currentGeneratedFiles.concat(this._generatedFiles);
+          return result;

Also applies to: 669-674


959-970: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Keep the blank-string default path reachable.

Lines 962-964 intentionally treat "" as “use the first generated file”, but the separate string branch at Lines 968-970 immediately overwrites targetFile with an empty lookup and then throws. Make this a single if / else if chain so the fallback survives.

💡 Proposed fix
-        if (typeof fileIdOrIndex === "number") {
+        else if (typeof fileIdOrIndex === "number") {
           targetFile = this._generatedFiles[fileIdOrIndex];
         }
         else if (typeof fileIdOrIndex === "string") {
           targetFile = this._generatedFiles.find(file => file.fileId === fileIdOrIndex || file.filename === fileIdOrIndex);
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/code.gs` around lines 959 - 970, The current branching allows the
blank-string check (typeof fileIdOrIndex === "string" && fileIdOrIndex.trim()
=== "") to set targetFile but then the later separate if for typeof
fileIdOrIndex === "number" / else if typeof fileIdOrIndex === "string"
overwrites it; change the control flow into a single if / else if / else chain
around fileIdOrIndex so the empty-string branch is mutually exclusive (e.g.,
check undefined/null, then trimmed-empty string, then number, then non-empty
string) and assign targetFile from this._generatedFiles accordingly (references:
fileIdOrIndex, targetFile, this._generatedFiles and the find using
file.fileId/file.filename).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/code.gs`:
- Around line 959-970: The current branching allows the blank-string check
(typeof fileIdOrIndex === "string" && fileIdOrIndex.trim() === "") to set
targetFile but then the later separate if for typeof fileIdOrIndex === "number"
/ else if typeof fileIdOrIndex === "string" overwrites it; change the control
flow into a single if / else if / else chain around fileIdOrIndex so the
empty-string branch is mutually exclusive (e.g., check undefined/null, then
trimmed-empty string, then number, then non-empty string) and assign targetFile
from this._generatedFiles accordingly (references: fileIdOrIndex, targetFile,
this._generatedFiles and the find using file.fileId/file.filename).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 845afd4d-2782-40c7-a3d7-0a9d67e5344f

📥 Commits

Reviewing files that changed from the base of the PR and between d62bf24 and 2aa7096.

📒 Files selected for processing (1)
  • src/code.gs
📜 Review details
🔇 Additional comments (1)
src/code.gs (1)

320-326: LGTM!

Also applies to: 900-910, 986-994, 1062-1066

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/code.gs`:
- Around line 327-331: Remove the leftover Git merge conflict markers
("<<<<<<<", "=======", ">>>>>>>") in the code and replace them with a single
empty line so the script contains no conflict artifacts; search for those
markers in src/code.gs (around where the diff shows the markers) and ensure the
final file has only one blank line in that spot and no other conflict markers
remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8a3a12ad-66ca-4823-91ce-66dfa1516b32

📥 Commits

Reviewing files that changed from the base of the PR and between 2aa7096 and 11715b3.

📒 Files selected for processing (1)
  • src/code.gs

Comment thread src/code.gs Outdated
aubrypaul and others added 2 commits June 9, 2026 16:31
…o-csv-conversion-utilities

Support spreadsheet attachments: convert XLSX/Sheets/ODS/XLS to CSV for Gemini
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/code.gs (1)

1032-1037: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Missing else reduces readability.

Line 1032 should be else if to match the existing conditional chain structure. While the current logic works correctly (because typeof undefined !== "number"), the inconsistent structure makes the flow harder to follow.

♻️ Suggested improvement
   else if (typeof fileIdOrIndex === "string" && fileIdOrIndex.trim() === "") {
     targetFile = this._generatedFiles[0];
   }
-  if (typeof fileIdOrIndex === "number") {
+  else if (typeof fileIdOrIndex === "number") {
     targetFile = this._generatedFiles[fileIdOrIndex];
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/code.gs` around lines 1032 - 1037, Change the conditional chain to be
explicit by using "else if" for the string branch so the flow is consistent and
more readable; locate the block that checks fileIdOrIndex (references: variable
fileIdOrIndex, assignment targetFile, and the _generatedFiles array) and replace
the standalone "if (typeof fileIdOrIndex === 'string')" with "else if (typeof
fileIdOrIndex === 'string')" so the numeric and string checks form a single
if/else-if chain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/code.gs`:
- Around line 358-362: There are stray tokens "return this;" and "};" outside
any function and a duplicated comment marker "/** OPTIONAL"; remove the two
standalone lines "return this;" and "};" (or if they belong to the preceding
method, move them inside that method so the function properly returns this and
closes with });) and delete the duplicate "/** OPTIONAL" so only one comment
remains; also scan the surrounding function/method (the one that should end
where these lines currently sit) to ensure its braces and return statement are
balanced and syntactically correct.

---

Outside diff comments:
In `@src/code.gs`:
- Around line 1032-1037: Change the conditional chain to be explicit by using
"else if" for the string branch so the flow is consistent and more readable;
locate the block that checks fileIdOrIndex (references: variable fileIdOrIndex,
assignment targetFile, and the _generatedFiles array) and replace the standalone
"if (typeof fileIdOrIndex === 'string')" with "else if (typeof fileIdOrIndex ===
'string')" so the numeric and string checks form a single if/else-if chain.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ad3fa90b-5324-45fd-ab3d-921d439d89b7

📥 Commits

Reviewing files that changed from the base of the PR and between 11715b3 and 3bc544b.

📒 Files selected for processing (1)
  • src/code.gs
📜 Review details
🔇 Additional comments (13)
src/code.gs (13)

165-218: LGTM!


757-796: LGTM!


925-981: LGTM!


1053-1061: LGTM!


1076-1113: LGTM!


1168-1172: LGTM!


1206-1209: LGTM!


2255-2270: LGTM!


2301-2343: LGTM!


2345-2362: LGTM!


2364-2384: LGTM!


2386-2429: LGTM!


2431-2470: LGTM!

Comment thread src/code.gs Outdated
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

❌ Failed to clone repository into sandbox. Please try again.

@aubrypaul

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aubrypaul

Copy link
Copy Markdown
Contributor

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/code.gs (1)

1032-1036: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Logic error: if should be else if causing empty string handling to fail.

Line 1032 uses if instead of else if. When fileIdOrIndex is an empty string:

  1. Line 1030 correctly sets targetFile = this._generatedFiles[0]
  2. Line 1032 doesn't match (not a number)
  3. Line 1035 matches (empty string is a string)
  4. Line 1036 overwrites targetFile to undefined (no file has fileId === "")
  5. Line 1038 throws "not found"
🐛 Proposed fix
-        if (typeof fileIdOrIndex === "number") {
+        else if (typeof fileIdOrIndex === "number") {
           targetFile = this._generatedFiles[fileIdOrIndex];
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/code.gs` around lines 1032 - 1036, Replace the second unconditional if
with an else if so the earlier branch that handles default/index values isn't
overwritten for empty-string inputs: in the method that sets targetFile (uses
this._generatedFiles and variable targetFile), change the `if (typeof
fileIdOrIndex === "number")` / subsequent `if (typeof fileIdOrIndex ===
"string")` sequence to `if (typeof fileIdOrIndex === "number") { ... } else if
(typeof fileIdOrIndex === "string") { ... }` so mounting a default targetFile
(e.g., this._generatedFiles[0]) isn't clobbered when fileIdOrIndex === "" and
targetFile remains valid.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/code.gs`:
- Around line 1032-1036: Replace the second unconditional if with an else if so
the earlier branch that handles default/index values isn't overwritten for
empty-string inputs: in the method that sets targetFile (uses
this._generatedFiles and variable targetFile), change the `if (typeof
fileIdOrIndex === "number")` / subsequent `if (typeof fileIdOrIndex ===
"string")` sequence to `if (typeof fileIdOrIndex === "number") { ... } else if
(typeof fileIdOrIndex === "string") { ... }` so mounting a default targetFile
(e.g., this._generatedFiles[0]) isn't clobbered when fileIdOrIndex === "" and
targetFile remains valid.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6d9eb69a-26a5-41c4-be3a-e583a75611a5

📥 Commits

Reviewing files that changed from the base of the PR and between c413ee2 and 3bc544b.

📒 Files selected for processing (2)
  • src/code.gs
  • src/testFunctions.gs
📜 Review details
🔇 Additional comments (14)
src/code.gs (10)

358-362: Critical syntax error: stray statements outside function scope.

Lines 358-359 contain return this; and }; outside of any function body. Line 361-362 shows a duplicated /** OPTIONAL comment. This will cause the script to fail at parse time.

This issue appears to persist from the previous review.


165-218: LGTM!


589-606: LGTM!


757-796: LGTM!


925-981: LGTM!


1048-1061: LGTM!


1075-1174: LGTM!


2255-2270: LGTM!


2301-2470: LGTM!


3018-3018: LGTM!

src/testFunctions.gs (4)

18-19: LGTM!


218-252: LGTM!


254-264: LGTM!


189-216: Fix: Ensure GEMINI_API_KEY is provided to testGeminiCodeExecution()

testGeminiCodeExecution() references GEMINI_API_KEY, but a repository search for GEMINI_API_KEY = in *.gs files returns no definition. The test therefore relies on the Apps Script runtime (or test harness/config) supplying GEMINI_API_KEY externally; make that setup explicit (or load it from a configuration source like properties) so the test doesn’t fail due to an undefined constant.

@aubrypaul

Copy link
Copy Markdown
Contributor

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/code.gs`:
- Around line 37-41: The code sets TIMEOUT_SECONDS using parseInt on
PropertiesService.getScriptProperties().getProperty which can yield NaN or
invalid values; update the initialization of TIMEOUT_SECONDS to defensively
parse and validate the property value (use parseInt or Number, check
isFinite/isNaN), fall back to the safe default (e.g., 360) when missing or
malformed, and clamp the result to allowed bounds (minimum sensible value and
maximum 1800) before using it; reference the TIMEOUT_SECONDS constant and the
call to PropertiesService.getScriptProperties().getProperty in your fix.
- Around line 2349-2383: The finally cleanup in _convertXlsxBlobToCsv can leave
temp files if Drive.Files.remove throws; wrap the
Drive.Files.remove(convertedFileId) call inside a try-catch so removal failures
are not swallowed silently—catch the error and log a clear message including
convertedFileId and originalFilename (e.g., via console.error) so admins can
investigate, but do not rethrow (we want the original error from
_spreadsheetToCsvResult to propagate if present).

In `@src/testFunctions.gs`:
- Around line 15-18: The commented-out call to testVision() lacks an
explanation; either restore or remove it. Update the invocation area (near
testVision(), testMaximumAPICalls(), testInputTokenWarning()) by adding a brief
comment stating why testVision() is disabled (e.g., requires API key, external
resources, or flaky) or delete the commented line entirely if the vision tests
are deprecated, and ensure any retained explanation mentions how/when to
re-enable the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ee34db71-8371-4bf8-ba0d-232566daa2c3

📥 Commits

Reviewing files that changed from the base of the PR and between c413ee2 and 35f0ecc.

📒 Files selected for processing (2)
  • src/code.gs
  • src/testFunctions.gs
📜 Review details
🔇 Additional comments (22)
src/code.gs (18)

170-223: LGTM!


340-362: LGTM!


591-608: LGTM!


759-800: LGTM!


945-1001: LGTM!


1044-1066: LGTM!


1068-1081: LGTM!


1095-1151: LGTM!


1206-1210: LGTM!


1244-1248: LGTM!


1831-1836: LGTM!


2293-2308: LGTM!


2385-2402: LGTM!


2404-2424: LGTM!


2426-2469: LGTM!


2471-2483: LGTM!


2485-2497: LGTM!


2499-2510: LGTM!

src/testFunctions.gs (4)

29-57: LGTM!


171-180: LGTM!


182-191: LGTM!


3-3: Confirm Gemini model ID: gemini-3.5-flash is the official API name.

gemini-3.5-flash is listed as the Gemini API model identifier in the official Gemini API docs, so the update in src/testFunctions.gs (line 3) aligns with the supported model name.

Comment thread src/code.gs Outdated
Comment thread src/code.gs
Comment thread src/testFunctions.gs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Code Interpreter support for Gemini

2 participants