Skip to content

Conversation

@jduncan-rva
Copy link

@jduncan-rva jduncan-rva commented Nov 23, 2025

Summary

This PR implements caching for the extension enablement configuration to prevent excessive file reads and error logging when the configuration file is invalid or missing. It also improves error reporting to include specific syntax errors.

Details

See above

Related Issues

N/A - uncovered this bug testing new extensions combinations.

How to Validate

have a typo in extension-enablement.json with an enable/disable list
start gemini (interactive or not)
you get multiple reports of an issue, but no details as to what/why

this gives you a better output and cuts out repetitive error noise.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@jduncan-rva jduncan-rva requested a review from a team as a code owner November 23, 2025 00:00
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jduncan-rva, 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 the robustness and performance of the extension enablement configuration management. By implementing a caching strategy, it prevents excessive file system operations and reduces the volume of error logs that occur when the configuration file is either missing or malformed. The changes also provide more informative error feedback, making it easier to diagnose configuration-related issues.

Highlights

  • Caching Mechanism: Introduced a caching layer for the extension enablement configuration to minimize redundant file reads.
  • Error Handling Improvement: Reduced error logging spam by caching invalid or missing configuration states, and enhanced error messages to include the specific file path.
  • Configuration Consistency: Ensured the in-memory cache is updated whenever the configuration is written to disk, maintaining data consistency.
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.

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 introduces caching for the extension enablement configuration, which is a good approach to prevent repeated file reads and error logging, especially for invalid or missing files. The implementation correctly caches the configuration on read and updates the cache on write. I've included one suggestion to refactor the error handling logic in readConfig. This refactoring will make the code more concise by removing duplication and will also enhance error reporting for JSON syntax errors, which aligns with one of the stated goals of this PR.

Comment on lines 189 to 205
} catch (error) {
if (
error instanceof Error &&
'code' in error &&
error.code === 'ENOENT'
(error as { code: string }).code === 'ENOENT'
) {
return {};
this.cachedConfig = {};
return this.cachedConfig;
}
coreEvents.emitFeedback(
'error',
'Failed to read extension enablement config.',
`Failed to read extension enablement config at ${this.configFilePath}.`,
error,
);
return {};
this.cachedConfig = {};
return this.cachedConfig;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The catch block can be refactored to be more concise and to better align with the PR's goal of improving error reporting for syntax errors. The current implementation contains duplicated code for caching an empty configuration and uses a generic error message for parsing failures.

By restructuring this block, we can:

  1. Eliminate code duplication for caching an empty config (this.cachedConfig = {}).
  2. Provide a more specific and helpful error message when JSON.parse fails due to a SyntaxError.
  3. Consistently cache an empty config on any read failure to prevent error spam, while selectively logging errors (i.e., not logging for a missing file, which is an expected condition).
Suggested change
} catch (error) {
if (
error instanceof Error &&
'code' in error &&
error.code === 'ENOENT'
(error as { code: string }).code === 'ENOENT'
) {
return {};
this.cachedConfig = {};
return this.cachedConfig;
}
coreEvents.emitFeedback(
'error',
'Failed to read extension enablement config.',
`Failed to read extension enablement config at ${this.configFilePath}.`,
error,
);
return {};
this.cachedConfig = {};
return this.cachedConfig;
}
} catch (error) {
const isEnoent =
error instanceof Error &&
'code' in error &&
(error as { code: string }).code === 'ENOENT';
if (!isEnoent) {
let message = `Failed to read or parse extension enablement config at ${this.configFilePath}.`;
if (error instanceof SyntaxError) {
message += `\nDetails: ${error.message}`;
}
coreEvents.emitFeedback('error', message, error);
}
this.cachedConfig = {};
return this.cachedConfig;
}

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.

1 participant