Skip to content

actually detect if zero is the set recommendedInterval#729

Merged
tavdog merged 3 commits intomainfrom
fix_recommendedInterval_zero_bug
Feb 27, 2026
Merged

actually detect if zero is the set recommendedInterval#729
tavdog merged 3 commits intomainfrom
fix_recommendedInterval_zero_bug

Conversation

@tavdog
Copy link
Member

@tavdog tavdog commented Feb 25, 2026

recommendedInterval = 0 was not working because 0 was considered no metadata.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tavdog, 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 addresses an issue where a recommendedInterval of 0 was incorrectly treated as missing metadata, causing the system to fall back to a default value of 10 minutes. The changes ensure that an explicitly configured 0 for the interval is respected. Additionally, the user interface has been improved to clearly display the recommended interval to users, providing better context for configuration.

Highlights

  • Corrected recommendedInterval handling for zero: The application now correctly interprets a recommendedInterval of 0 as an explicitly set value, rather than defaulting to 10 minutes due to misinterpreting 0 as an absence of metadata.
  • Introduced hasMetadata flag: A new boolean flag, hasMetadata, was added to distinguish between cases where no metadata is found and cases where metadata explicitly sets recommendedInterval to 0.
  • Enhanced UI for recommended interval: The configuration page for applications now displays the recommended interval next to the "Render Interval Minutes" label and uses it as a placeholder in the input field when metadata is available.
  • Added i18n string: A new internationalization string for "recommended" was added to support the updated UI.
Changelog
  • internal/server/handlers_app.go
    • Introduced a hasMetadata boolean flag to track if application metadata was successfully retrieved.
    • Modified the logic for determining uinterval to only fall back to 10 minutes if no metadata was found, allowing 0 to be a valid explicit setting.
    • Updated the comment for the default recommendedInterval to clarify it's the default when no metadata is present.
  • web/i18n/en.json
    • Added a new translation entry for the term 'recommended'.
  • web/templates/manager/configapp.html
    • Updated the 'Render Interval Minutes' label to conditionally display the AppMetadata.RecommendedInterval.
    • Set the placeholder attribute of the interval input field to AppMetadata.RecommendedInterval when application metadata is available.
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 correctly fixes an issue where a recommendedInterval of 0 was not being respected when adding a new app, properly distinguishing between an explicitly set zero interval and the absence of metadata using the hasMetadata flag. However, it introduces a potential security risk where the update interval (uinterval) could be set to a non-positive value. If this value is later used in a scheduling context (e.g., with time.NewTicker) without further validation, it could cause the server to panic, leading to a denial-of-service. Additionally, there's an opportunity to simplify the interval calculation logic in internal/server/handlers_app.go by removing a redundant condition, which would improve code clarity and maintainability.

Comment on lines 140 to 146
if uinterval == 0 || (uinterval == 10 && recommendedInterval != 10) {
uinterval = recommendedInterval
}
if uinterval == 0 {
// Only fall back to 10 if no metadata was found (0 is valid when explicitly set)
if uinterval == 0 && !hasMetadata {
uinterval = 10
}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The current logic for calculating uinterval allows it to be set to a non-positive value (0 or negative) if the user provides such a value or if metadata specifies it. This is a critical security concern because many scheduling systems, such as Go's time.NewTicker, will panic if provided with a non-positive interval, potentially leading to a remote denial-of-service. While the PR aims to allow 0 as a valid value, explicit validation is needed to ensure uinterval is positive before it's used in a scheduler. Additionally, the if statement on line 144 appears to be unreachable and redundant, as the preceding logic on line 140 ensures uinterval will be non-zero if !hasMetadata. Simplifying this by removing the redundant check, as suggested, would improve clarity and maintainability.

// Use recommended_interval logic. If the user didn't specify an interval,
	// or used the old default of 10, use the recommended interval.
	if uinterval == 0 || (uinterval == 10 && recommendedInterval != 10) {
		uinterval = recommendedInterval
	}

@tavdog tavdog merged commit 7be3abd into main Feb 27, 2026
12 checks passed
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