Skip to content

fix: assign decodedData when input is string#629

Merged
MarvelNwachukwu merged 2 commits intomainfrom
fix-uninitialized-decodedData
Mar 19, 2026
Merged

fix: assign decodedData when input is string#629
MarvelNwachukwu merged 2 commits intomainfrom
fix-uninitialized-decodedData

Conversation

@MarvelNwachukwu
Copy link
Copy Markdown
Contributor

@MarvelNwachukwu MarvelNwachukwu commented Mar 19, 2026

Description

When reading file content, the code had a bug where it only handled one type of input (binary data) but forgot to handle the other (plain text). This meant passing text to the function would silently break because the variable holding the result was never set. The fix simply assigns the text input so both paths work correctly.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

All existing tests pass (478 tests in the adk package). The fix ensures both input types (binary and text) are properly handled before use.

Checklist

  • Code follows the code style of this project
  • All new and existing tests passed
  • Changes generate no new warnings

Fixes uninitialized variable bug where decodedData was undefined when the input parameter was already a string, causing subsequent calls to isBase64Encoded and btoa to fail.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
adk-typescript-docs Ready Ready Preview Mar 19, 2026 3:40pm
adk-web Ready Ready Preview Mar 19, 2026 3:40pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: deb7ec5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@iqai/adk Patch
@iqai/adk-cli Patch
@iqai/mcp-docs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug in the CodeExecutionUtils class that caused decodedData to be uninitialized when processing string inputs. By ensuring decodedData is always assigned, the change prevents undefined values from being passed to subsequent encoding functions, thereby improving the stability and correctness of file content handling.

Highlights

  • Bug Fix: Addressed an uninitialized variable bug in CodeExecutionUtils.getEncodedFileContent() where decodedData was not assigned when the input data was already a string, preventing runtime errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request correctly fixes a bug where decodedData was uninitialized if the input was a string. I've added one suggestion to make the code more concise by using a ternary operator for initialization, which also allows for using const.

Comment on lines 36 to 41
let decodedData: string;
if (data instanceof ArrayBuffer) {
decodedData = new TextDecoder().decode(data);
} else {
decodedData = data;
}
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.

medium

While the fix is correct, this logic can be made more concise by using a ternary operator for initialization. This also allows decodedData to be declared with const, which is a good practice for variables that are not reassigned.

Suggested change
let decodedData: string;
if (data instanceof ArrayBuffer) {
decodedData = new TextDecoder().decode(data);
} else {
decodedData = data;
}
const decodedData = data instanceof ArrayBuffer ? new TextDecoder().decode(data) : data;

Address PR feedback: simplify if/else to const ternary assignment.
Add changeset for patch version bump.
@MarvelNwachukwu MarvelNwachukwu merged commit 3c484d5 into main Mar 19, 2026
4 of 6 checks passed
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.

fix: uninitialized decodedData in getEncodedFileContent

1 participant