Skip to content

Fix log config inputs not allowing for zero#579

Merged
Flaminel merged 2 commits into
mainfrom
fix_log_inputs
Apr 22, 2026
Merged

Fix log config inputs not allowing for zero#579
Flaminel merged 2 commits into
mainfrom
fix_log_inputs

Conversation

@Flaminel

@Flaminel Flaminel commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Relates to #569

Summary by Sourcery

Allow zero values for log configuration limits while enforcing sensible validation rules when archiving is enabled.

Bug Fixes:

  • Fix log configuration inputs rejecting zero values despite UI hints indicating zero is a valid option.
  • Prevent invalid configuration where both archive retained count and archive time limit are set to zero when archiving is enabled.

Enhancements:

  • Align frontend numeric input constraints with updated log configuration semantics for rolling size, retained files, time limits, and archive settings.

@Flaminel

Copy link
Copy Markdown
Contributor Author

@sourcery-ai review

@sourcery-ai

sourcery-ai Bot commented Apr 22, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts general log settings validation and UI to allow zero values for several numeric fields while preventing an invalid combination for archive settings when archiving is enabled.

Sequence diagram for updated log archive validation when zero values are allowed

sequenceDiagram
  actor User
  participant LogSettingsForm
  participant GeneralSettingsComponent

  User->>LogSettingsForm: Enter values for archiveRetainedCount and archiveTimeLimitHours
  LogSettingsForm->>GeneralSettingsComponent: Update logArchiveRetainedCount
  GeneralSettingsComponent->>GeneralSettingsComponent: compute logArchiveRetainedError()
  alt retainedCount < 0
    GeneralSettingsComponent-->>LogSettingsForm: error Minimum value is 0
  else retainedCount > 100
    GeneralSettingsComponent-->>LogSettingsForm: error Maximum value is 100
  else archiving enabled AND retainedCount == 0 AND archiveTimeLimitHours == 0
    GeneralSettingsComponent-->>LogSettingsForm: error Retained count and time limit cannot both be 0 when archiving is enabled
  else
    GeneralSettingsComponent-->>LogSettingsForm: no error
  end

  LogSettingsForm->>GeneralSettingsComponent: Update logArchiveTimeLimitHours
  GeneralSettingsComponent->>GeneralSettingsComponent: compute logArchiveTimeLimitError()
  alt timeLimit < 0
    GeneralSettingsComponent-->>LogSettingsForm: error Minimum value is 0
  else timeLimit > 1440
    GeneralSettingsComponent-->>LogSettingsForm: error Maximum value is 1440 hours (60 days)
  else archiving enabled AND timeLimit == 0 AND archiveRetainedCount == 0
    GeneralSettingsComponent-->>LogSettingsForm: error Retained count and time limit cannot both be 0 when archiving is enabled
  else
    GeneralSettingsComponent-->>LogSettingsForm: no error
  end

  LogSettingsForm-->>User: Show updated validation messages and allow zero where valid
Loading

File-Level Changes

Change Details Files
Relax minimum validation for log rolling size, time limits, and archive limits to allow zero where 0 has a special meaning.
  • Update computed validation for logRollingSizeMB to accept 0 as minimum instead of 1, keeping 100 MB as maximum.
  • Update computed validation for logTimeLimitHours to accept 0 as minimum instead of 1, keeping 1440 hours as maximum.
  • Update computed validation for logArchiveTimeLimitHours to accept 0 as minimum instead of 1, keeping 1440 hours as maximum.
code/frontend/src/app/features/settings/general/general-settings.component.ts
Prevent enabling log archiving with both retained count and time limit set to zero.
  • Extend logArchiveRetainedError to return a specific error when archiving is enabled and both retained count and archive time limit are 0.
  • Extend logArchiveTimeLimitError to return a specific error when archiving is enabled and both archive time limit and retained count are 0.
code/frontend/src/app/features/settings/general/general-settings.component.ts
Align number input component constraints in the template with the new validation rules that allow zero values.
  • Change [min] bindings from 1 to 0 for Rolling Size, Retained Files, and Time Limit inputs.
  • Change [min] bindings from 1 to 0 for Archive Retained Count and Archive Time Limit inputs.
code/frontend/src/app/features/settings/general/general-settings.component.html

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The cross-field validation that logArchiveRetainedCount and logArchiveTimeLimitHours cannot both be 0 when archiving is enabled is duplicated in two computed error functions; consider extracting this into a shared helper or a single computed to avoid divergence and simplify future changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The cross-field validation that `logArchiveRetainedCount` and `logArchiveTimeLimitHours` cannot both be 0 when archiving is enabled is duplicated in two computed error functions; consider extracting this into a shared helper or a single computed to avoid divergence and simplify future changes.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Flaminel Flaminel merged commit 41ca55d into main Apr 22, 2026
6 of 10 checks passed
@Flaminel Flaminel deleted the fix_log_inputs branch April 22, 2026 13:15
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