Skip to content

Add studio.json as an alternative to metadata.json#10061

Merged
christhompsongoogle merged 4 commits intomainfrom
renamestudio
Mar 13, 2026
Merged

Add studio.json as an alternative to metadata.json#10061
christhompsongoogle merged 4 commits intomainfrom
renamestudio

Conversation

@christhompsongoogle
Copy link
Contributor

Add studio.json as an alternative

@gemini-code-assist
Copy link
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 enhances the flexibility of configuration file handling by allowing the system to recognize studio.json in addition to metadata.json. This change provides an alternative naming convention for project metadata, ensuring that the system can adapt to different file structures while maintaining backward compatibility with existing metadata.json files.

Highlights

  • Configuration File Flexibility: Introduced support for studio.json as an alternative configuration file, giving it preference over the existing metadata.json when both are present.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/firebase_studio/migrate.ts
    • Modified the extractMetadata function to check for studio.json before metadata.json when parsing project metadata.
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 aims to add support for studio.json as an alternative to metadata.json. However, the current implementation introduces a significant logic error in the metadata extraction process. By using forEach with an async callback, the code fails to wait for metadata files to be read, which can lead to security risks such as uploading secrets to the wrong Firebase project if a fallback project ID is used from .firebaserc. This also creates a race condition, preventing metadata from being loaded correctly and ignoring the intended preference for studio.json.

Comment on lines +118 to +125
[metadataPath, studioJsonPath].forEach(async (path) => {
try {
const metadataContent = await fs.readFile(path, "utf8");
metadata = JSON.parse(metadataContent) as Metadata;
} catch (err: unknown) {
logger.debug(`Could not read metadata.json at ${path}: ${err}`);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

security-high high

The extractMetadata function uses a forEach loop with an async callback to read metadata from studio.json or metadata.json. This approach is problematic because forEach does not await the completion of asynchronous operations. As a result, the metadata object remains empty when the code proceeds to determine the projectId on line 127. This can cause the migration process to ignore the project ID specified in the metadata files and potentially fall back to an incorrect or malicious project ID from .firebaserc, leading to sensitive information, such as the GEMINI_API_KEY from .env, being uploaded to the wrong Firebase project. Additionally, the intended preference for studio.json is not guaranteed due to a race condition between the file reads. The variable metadataFile inside the loop also shadows the imported path module, and the debug log message hardcodes "metadata.json" instead of using the variable metadataFile.

Suggested change
[metadataPath, studioJsonPath].forEach(async (path) => {
try {
const metadataContent = await fs.readFile(path, "utf8");
metadata = JSON.parse(metadataContent) as Metadata;
} catch (err: unknown) {
logger.debug(`Could not read metadata.json at ${path}: ${err}`);
}
});
for (const metadataFile of [metadataPath, studioJsonPath]) {
try {
const metadataContent = await fs.readFile(metadataFile, "utf8");
metadata = JSON.parse(metadataContent) as Metadata;
} catch (err: unknown) {
logger.debug(`Could not read metadata.json at ${metadataFile}: ${err}`);
}
}

for (const metadataFile of [metadataPath, studioJsonPath]) {
try {
const metadataContent = await fs.readFile(metadataFile, "utf8");
metadata = JSON.parse(metadataContent) as Metadata;
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a debug log that makes it explicit which file is used? Right now, i could see folks getting confused by this logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@christhompsongoogle christhompsongoogle enabled auto-merge (squash) March 13, 2026 18:12
@christhompsongoogle christhompsongoogle merged commit 74ecb58 into main Mar 13, 2026
47 checks passed
@christhompsongoogle christhompsongoogle deleted the renamestudio branch March 13, 2026 18:24
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.

3 participants