Skip to content

Comments

fix: register all projects in profile cache to prevent lookup errors#310

Open
phelype123 wants to merge 1 commit intoautomagik-dev:mainfrom
phelype123:main
Open

fix: register all projects in profile cache to prevent lookup errors#310
phelype123 wants to merge 1 commit intoautomagik-dev:mainfrom
phelype123:main

Conversation

@phelype123
Copy link

Summary

  • Fixed "Project not registered in profile cache" errors that occurred when accessing profiles for projects without .genie folders
  • Now all projects are registered in the profile cache during startup, not just those with .genie folders
  • Projects with profile loading errors are also registered to prevent cache lookup failures

Test plan

  • Start the forge server with a mix of projects (some with .genie folders, some without)
  • Verify no "not registered in profile cache" errors in logs
  • Access /api/forge/projects/{id}/profiles endpoint for projects without .genie folder
  • Verify background worktree cleanup works without profile cache errors

🤖 Generated with Claude Code

Previously, only projects with .genie folders were registered in the
profile cache during startup. This caused "Project not registered in
profile cache" errors when accessing profiles for projects without
.genie folders.

Now all projects are registered:
- Projects with .genie folder: registered with custom profiles
- Projects without .genie folder: registered with default profiles
- Projects with profile loading errors: still registered to prevent
  cache lookup failures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @phelype123, 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 critical profile cache lookup errors by enhancing the project registration process during application startup. Previously, only projects with a .genie folder or successfully loaded profiles were registered, leading to errors for other projects. The updated logic now guarantees that every project is registered in the profile cache, even if it lacks a .genie folder or encounters profile loading issues, thereby improving the system's stability and preventing runtime failures.

Highlights

  • Error Prevention: Eliminates "Project not registered in profile cache" errors by ensuring all projects are registered in the profile cache during startup.
  • Universal Registration: Modifies the startup logic to register all projects in the profile cache, irrespective of whether they contain a .genie folder.
  • Robustness: Ensures that projects encountering profile loading errors are still registered in the cache, preventing subsequent cache lookup failures.
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 fixes an issue where projects without a .genie folder or with profile loading errors were not registered in the profile cache, leading to lookup errors. The changes correctly modify the logic to ensure all projects are registered at startup. I've found a small opportunity to improve code maintainability by removing some duplication, which I've detailed in a specific comment.

Comment on lines 214 to +245
self.profile_cache
.register_project(project.id, project.git_repo_path.clone())
.await;

tracing::info!(
"✅ Loaded {} profile variants for project: {} (registered project_id: {})",
variant_count,
project.name,
project.id
);

loaded_count += 1;
total_variants += variant_count;
if has_genie_folder {
tracing::info!(
"✅ Loaded {} profile variants for project: {} (registered project_id: {})",
variant_count,
project.name,
project.id
);
loaded_count += 1;
total_variants += variant_count;
} else {
tracing::debug!(
"Registered project '{}' (id: {}) with default profiles (no .genie folder)",
project.name,
project.id
);
}
}
Err(e) => {
tracing::warn!(
"⚠️ Failed to load .genie profiles for project '{}': {}",
"⚠️ Failed to load profiles for project '{}': {}",
project.name,
e
);
// Don't fail startup if one project has invalid profiles
// Still register the project even if profile loading fails
// This prevents "not registered in profile cache" errors
self.profile_cache
.register_project(project.id, project.git_repo_path.clone())
.await;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's some code duplication here. The call to self.profile_cache.register_project(...) is present in both the Ok (lines 214-216) and Err (lines 243-245) arms of the match. To improve maintainability and reduce duplication, consider moving this call to before the match statement. This would make it clear that every project is registered regardless of the outcome of loading profiles.

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