Skip to content

Conversation

@kooksee
Copy link
Contributor

@kooksee kooksee commented Jan 23, 2026

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @kooksee, 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 introduces several new features and improvements to the funk library. It adds modules for HTTP-based feature flag management and file-based configuration monitoring, enhances configuration capabilities with CEL expressions and environment variable validation, and refactors logging for better consistency and maintainability. These changes aim to provide more flexible, secure, and manageable runtime configuration options.

Highlights

  • Dependency Updates: Updates several dependencies, including ent, go-github, and testcontainers, ensuring compatibility and access to the latest features and security patches.
  • Feature HTTP Module: Introduces a new Feature HTTP module, providing a web interface to view and manage feature flags, enhancing runtime configuration management.
  • Feature Watcher Module: Adds a Feature Watcher module that monitors a directory for file changes and automatically applies them to feature flags, enabling dynamic configuration updates without restarts.
  • Configuration Management Enhancements: Improves configuration management with CEL expressions, environment variable validation, and secure path handling, offering more flexible and secure configuration options.
  • Logging Improvements: Refactors logging to use a consistent event structure and removes direct zerolog dependencies from components, promoting better maintainability.

🧠 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.

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

@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 a new self-upgrade command and significantly refactors the configuration management and error handling mechanisms. The config package now leverages a CEL expression engine for dynamic configuration values and enforces explicit declaration of environment variables, enhancing security and maintainability. The result package has been updated to provide more consistent error wrapping and logging. Additionally, new featurehttp and featurewatcher modules are introduced for managing feature flags. The changes are well-structured and improve the overall robustness and security of the codebase.

Comment on lines +43 to +50
safePath, err := securePath(cfg.workDir, name)
if err != nil {
log.Error().Err(err).
Str("name", name).
Str("workDir", cfg.workDir).
Msg("embed: path security check failed")
return types.String("")
}

Choose a reason for hiding this comment

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

security-critical critical

The securePath function is correctly used within the embed CEL function to prevent path traversal attacks. This is a critical security measure, ensuring that embed can only access files within the designated workDir and cannot be exploited to read arbitrary files on the system.

Comment on lines +12 to +41
func securePath(baseDir, name string) (string, error) {
if name == "" {
return "", errors.New("file name is empty")
}

// Reject absolute paths immediately
if filepath.IsAbs(name) {
return "", errors.Errorf("path traversal detected: absolute path %q not allowed", name)
}

// Clean and resolve the path
absBase, err := filepath.Abs(baseDir)
if err != nil {
return "", errors.Wrap(err, "failed to get absolute base path")
}

// Join and clean the target path
targetPath := filepath.Join(absBase, name)
absTarget, err := filepath.Abs(targetPath)
if err != nil {
return "", errors.Wrap(err, "failed to get absolute target path")
}

// Ensure the target is within the base directory
// Add trailing separator to prevent prefix attacks (e.g., /base-evil matching /base)
if !strings.HasPrefix(absTarget, absBase+string(filepath.Separator)) && absTarget != absBase {
return "", errors.Errorf("path traversal detected: %q escapes base directory %q", name, baseDir)
}

return absTarget, nil

Choose a reason for hiding this comment

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

security-critical critical

The securePath function is a critical security component. It correctly validates that any resolved path stays within the specified base directory, effectively preventing path traversal vulnerabilities. This is essential for functions like embed() that read files based on user-provided paths.

Comment on lines +239 to +242
if cfg.envSpecMap != nil {
if _, defined := cfg.envSpecMap[name]; !defined {
return -1, fmt.Errorf("env: variable %q is not defined in envs, all env vars must be declared", name)
}

Choose a reason for hiding this comment

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

security-high high

This check ensures that any environment variable used in the configuration via ${ENV} syntax must be explicitly declared in patch_envs. This is a high-severity security and maintainability feature, preventing accidental use of undeclared environment variables and making the configuration more explicit and auditable.

ProgressListener: defaultProgressBar,
}
assert.Must(c.Get())
assert.Must(os.Rename(filepath.Join(downloadDir, asset.Filename), execFile))

Choose a reason for hiding this comment

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

high

Renaming the downloaded file directly over the running executable (execFile) is a high-risk operation. On Windows, this operation will likely fail if the executable is in use. On POSIX systems, while os.Rename is atomic for files on the same filesystem, an interruption or failure could leave the executable in a corrupted state. A safer approach would involve:

  1. Downloading to a temporary file.
  2. Verifying the downloaded file (e.g., checksum).
  3. Moving the old executable to a backup location.
  4. Renaming the new executable to the original executable's path.
  5. Cleaning up the backup on successful restart or keeping it for rollback.

Comment on lines +87 to +91
if cfg.envSpecMap != nil {
key = strings.TrimSpace(strings.ToUpper(key))
if _, defined := cfg.envSpecMap[key]; !defined {
return types.NewErr("env: variable %q is not defined in patch_envs, all env vars must be declared", key)
}

Choose a reason for hiding this comment

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

security-high high

The env CEL function correctly validates that environment variables are explicitly defined in patch_envs. This is a high-severity security and maintainability feature, preventing accidental exposure of undeclared environment variables and ensuring that all configuration dependencies are explicit.


// FlatMap calls fn with the value if the result is OK, then returns the result unchanged.
func (r Result[T]) FlatMap(fn func(val T) Result[T]) Result[T] {
// MapVal calls fn with the value if the result is OK, then returns the result unchanged.

Choose a reason for hiding this comment

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

medium

Renaming FlatMap to MapVal improves semantic clarity, as it better describes the operation of mapping a value to another Result.

// panicIfError logs the error and panics
// This maintains backward compatibility with existing code that expects panics
func panicIfError(err error, events ...func(e *zerolog.Event)) {
func panicIfError(err error, events ...func(e Event)) {

Choose a reason for hiding this comment

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

medium

Using the new result.Event type for panicIfError ensures a consistent logging interface within the result package, abstracting the underlying logger implementation.

// err - The error to log
// events - Optional functions to add additional log fields
func logErr(ctx context.Context, skip int, err error, events ...func(e *zerolog.Event)) {
func logErr(ctx context.Context, skip int, err error, events ...func(e Event)) {

Choose a reason for hiding this comment

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

medium

Using the new result.Event type for logErr ensures a consistent logging interface within the result package, abstracting the underlying logger implementation.

Comment on lines +374 to +376
evt := Event{e}
for _, fn := range events {
fn(e)
fn(evt)

Choose a reason for hiding this comment

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

medium

The logErr function now correctly wraps the zerolog.Event into a result.Event before passing it to the provided event functions. This maintains the new consistent logging interface and ensures that custom log fields are added through the result.Event abstraction.

Comment on lines +20 to 22
result.ErrOf(cmd.Run()).Log(func(e result.Event) {
e.Msgf("failed to execute: %q", args)
})

Choose a reason for hiding this comment

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

medium

Using the new result.Event type and e.Msgf for logging in Run ensures a consistent logging interface within the result package, abstracting the underlying logger implementation.

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.

2 participants