Skip to content

Comments

Disallow unsafe returns.#19767

Merged
gundermanc merged 2 commits intomainfrom
gundermanc/disallow-unsafe-returns
Feb 21, 2026
Merged

Disallow unsafe returns.#19767
gundermanc merged 2 commits intomainfrom
gundermanc/disallow-unsafe-returns

Conversation

@gundermanc
Copy link
Member

@gundermanc gundermanc commented Feb 21, 2026

Summary

Disallow unsafe returns (returns with any type).

Fixes: #19720

@gundermanc gundermanc requested a review from a team as a code owner February 21, 2026 00:25
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gundermanc, 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 significantly improves type safety by introducing and enforcing the @typescript-eslint/no-unsafe-return ESLint rule. This rule prevents the return of any types, which helps to catch potential type-related errors early and promotes more predictable code behavior. To integrate this new rule without introducing immediate build failures, existing code that violates the rule has been explicitly marked with ESLint disable comments, allowing for a phased approach to full type compliance.

Highlights

  • ESLint Rule Enforcement: The @typescript-eslint/no-unsafe-return ESLint rule has been enabled to prevent functions from returning values of type any, thereby enhancing type safety across the codebase.
  • Existing Violation Suppression: Numerous existing instances where the newly enabled rule would have flagged issues have been addressed by adding // eslint-disable-next-line @typescript-eslint/no-unsafe-return comments to suppress the warnings.
Changelog
  • eslint.config.js
    • Enabled the @typescript-eslint/no-unsafe-return rule.
  • packages/a2a-server/src/config/settings.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/commands/extensions/utils.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/config/extensionRegistryClient.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/config/extensions/extensionEnablement.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/config/extensions/extensionSettings.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/config/extensions/variables.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/test-utils/mockCommandContext.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/ui/hooks/useAtCompletion.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress new ESLint warnings in two functions.
  • packages/cli/src/ui/utils/TableRenderer.tsx
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/utils/activityLogger.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/utils/envVarResolver.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/utils/gitUtils.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/utils/jsonoutput.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/utils/settingsUtils.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/cli/src/zed-integration/fileSystemService.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/core/src/code_assist/oauth2.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/core/src/config/projectRegistry.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/core/src/core/baseLlmClient.ts
    • Updated import statements for ContentGenerator and AuthType.
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/core/src/core/fakeContentGenerator.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress new ESLint warnings in two methods.
  • packages/core/src/ide/ide-client.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/core/src/ide/ide-connection-utils.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress new ESLint warnings in multiple return statements.
  • packages/core/src/services/chatRecordingService.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/core/src/utils/filesearch/fileSearch.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress a new ESLint warning.
  • packages/core/src/utils/safeJsonStringify.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress new ESLint warnings in two functions.
  • packages/core/src/utils/stdio.ts
    • Added // eslint-disable-next-line @typescript-eslint/no-unsafe-return to suppress new ESLint warnings in proxy getters.
Activity
  • No specific human activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

@github-actions
Copy link

github-actions bot commented Feb 21, 2026

Size Change: +375 B (0%)

Total Size: 25.2 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.2 MB +375 B (0%)
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

Copy link
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

This pull request is a great step towards improving type safety by enabling the @typescript-eslint/no-unsafe-return ESLint rule. My review focuses on areas where the newly flagged errors can be resolved with simple type assertions or annotations rather than just suppressing the rule. These changes will enhance the overall type safety and clarity of the code.

Comment on lines +50 to 51
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return response.confirm;
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of disabling the no-unsafe-return rule, you can ensure type safety by explicitly converting the returned value to a boolean. The response.confirm property from the prompts library is of type any, but this function is expected to return a boolean. Using !! is a concise way to guarantee a boolean return value.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return response.confirm;
return !!response.confirm;

Comment on lines +86 to 87
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return results.map((r: { item: RegistryExtension }) => r.item);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of disabling the no-unsafe-return rule, you can fix the underlying type issue. The results variable is inferred as any due to the no-unsafe-assignment suppression. By casting results to its expected type, you can ensure type safety for the return value and remove the need for this suppression.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return results.map((r: { item: RegistryExtension }) => r.item);
return (results as Array<{ item: RegistryExtension }>).map((r) => r.item);

Comment on lines +182 to 183
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(content);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of suppressing the no-unsafe-return error, it's better to explicitly cast the result of JSON.parse to the expected return type AllExtensionsEnablementConfig. This improves type safety and makes the code clearer.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(content);
return JSON.parse(content) as AllExtensionsEnablementConfig;

Comment on lines +159 to 160
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return response.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of suppressing the no-unsafe-return error, you can ensure type safety by casting the any value from the prompts library to the expected string type.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return response.value;
return response.value as string;

Comment on lines +173 to 176
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return results.map(
(result: { item: ResourceSuggestionCandidate }) => result.item.suggestion,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of disabling the no-unsafe-return rule, you can fix the underlying type issue. The results variable is inferred as any. By casting results to its expected type, you can ensure type safety for the return value and remove the need for this suppression.

  return (results as Array<{ item: ResourceSuggestionCandidate }>).map(
    (result) => result.item.suggestion,
  );

Comment on lines +165 to 168
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(
this.cleanJsonResponse(getResponseText(result)!.trim(), model),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of suppressing the no-unsafe-return error, it's better to explicitly cast the result of JSON.parse to the expected Record<string, unknown> type. This improves type safety.

    return JSON.parse(
      this.cleanJsonResponse(getResponseText(result)!.trim(), model),
    ) as Record<string, unknown>;

Comment on lines +351 to 352
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return parsedJson.content;
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of suppressing the no-unsafe-return error, you can ensure type safety by casting parsedJson.content to a string. The parsedJson object is of type any, so this cast clarifies the intended return type.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return parsedJson.content;
return parsedJson.content as string;

Comment on lines +126 to 127
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(portFileContents);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of suppressing the no-unsafe-return error, it's better to explicitly cast the result of JSON.parse to the function's expected return type. This improves type safety.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(portFileContents);
return JSON.parse(portFileContents) as ConnectionConfig & { workspacePath?: string; ideInfo?: IdeInfo };

Comment on lines +171 to 172
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(content);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of suppressing the no-unsafe-return error, it's better to explicitly cast the result of JSON.parse to the expected type within the map. This improves type safety for the parsedContents array, which will in turn resolve the other no-unsafe-return issues later in this function.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(content);
return JSON.parse(content) as (ConnectionConfig & { workspacePath?: string; ideInfo?: IdeInfo });

Comment on lines +422 to 423
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(this.cachedLastConvData);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Instead of suppressing the no-unsafe-return error, it's better to explicitly cast the result of JSON.parse to the expected ConversationRecord type. This improves type safety.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.parse(this.cachedLastConvData);
return JSON.parse(this.cachedLastConvData) as ConversationRecord;

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Feb 21, 2026
@gundermanc gundermanc added this pull request to the merge queue Feb 21, 2026
Merged via the queue into main with commit dfd7721 Feb 21, 2026
27 checks passed
@gundermanc gundermanc deleted the gundermanc/disallow-unsafe-returns branch February 21, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disallow unsafe returns

2 participants