Skip to content

Add config.defaults.version compatibility option#139

Open
rgerhards wants to merge 1 commit intoratelimit-refactorfrom
codex/add-global-config-for-version-override
Open

Add config.defaults.version compatibility option#139
rgerhards wants to merge 1 commit intoratelimit-refactorfrom
codex/add-global-config-for-version-override

Conversation

@rgerhards
Copy link
Owner

Summary

  • add a config.defaults.version global option that records the release baseline for built-in defaults
  • validate the YYMM input, keep the default pinned to February 2003 compatibility, and store the parsed metadata on the configuration defaults
  • document the new knob in the Rainerscript global() reference

Testing

  • not run (not requested)

https://chatgpt.com/codex/tasks/task_e_68e125b1ca588332860ee1898f18c1eb

@gemini-code-assist
Copy link

Summary of Changes

Hello @rgerhards, 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 a new configuration mechanism to manage the compatibility of rsyslog's built-in defaults. By adding a config.defaults.version global option, administrators can now explicitly define a historical release vintage (in YYMM format) that rsyslog should emulate for its default behaviors. This change ensures that existing deployments can maintain their current operational characteristics, while also providing a path for new installations to adopt modernized defaults as they become available. The implementation includes input validation for the version string and comprehensive documentation.

Highlights

  • New Global Option: Introduced config.defaults.version as a new global option, allowing users to specify a YYMM value to control the baseline for rsyslog's built-in defaults.
  • Input Validation: Added robust validation for the YYMM input, ensuring it is a four-digit string with a valid month (01-12) and reporting errors for invalid formats.
  • Compatibility Baseline: The default compatibility is set to February 2003 (0302), allowing existing deployments to maintain older behaviors while new installations can opt into modernized defaults.
  • Documentation: The new config.defaults.version option has been thoroughly documented in the Rainerscript global() reference, explaining its purpose, format, and impact.
  • Future-Proofing: The parsed compatibility version (year, month, and combined YYMM) is stored within the configuration, preparing rsyslog for future releases to consume this information and dynamically adjust default behaviors.
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.

gemini-code-assist[bot]

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Oct 4, 2025

📖 Documentation Preview Ready!

Sphinx docs built and deployed for this PR.

🌐 Browse Online (Recommended):

📚 View Documentation Online →

🔗 Quick Links:


🤖 This comment was generated by the docs workflow.

@rgerhards
Copy link
Owner Author

/gemini review

@rgerhards rgerhards self-assigned this Oct 4, 2025
@rgerhards rgerhards added this to the v8.25010 milestone Oct 4, 2025
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 config.defaults.version compatibility option, which is a great step towards modernizing defaults while maintaining backward compatibility. The implementation is solid, with good validation of the new configuration value. The documentation is also clear and helpful. My only suggestion is to refactor a piece of validation logic to improve its readability and maintainability.

Comment on lines +421 to +427
const long ver = strtol(value, &endptr, 10);
if (endptr != value + 4 || endptr == value || *endptr != '\0') {
parser_errmsg(
"config.defaults.version must be a 4-digit YYMM value; invalid value '%s' ignored (keeping %02u%02u)",
value, prevYear, prevMonth);
return;
}

Choose a reason for hiding this comment

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

medium

The validation logic to ensure the value is a 4-digit string is functionally correct, but it's a bit complex and hard to understand at a glance. The condition endptr != value + 4 is a clever but obscure way to check for string length.

Refactoring this into a more straightforward check would improve code readability and maintainability. A clearer approach would be to first check the string length and then verify that it contains only digits.

    const long ver = strtol(value, &endptr, 10);
    if (strlen(value) != 4 || *endptr != '\0') {
        parser_errmsg(
            "config.defaults.version must be a 4-digit YYMM value; invalid value '%s' ignored (keeping %02u%02u)",
            value, prevYear, prevMonth);
        return;
    }

This prepares rsyslog to expose "versioned defaults" for new installs
while keeping full backward compatibility for existing deployments. It
adds a global knob that is parsed and stored now; later releases will
consume it to switch baseline behavior.

Impact: No default behavior change. New knob is validated; misconfig
yields a config error and the previous baseline is retained.

Before: no way to declare a defaults baseline in config.
After: global 'config.defaults.version' (YYMM) is accepted, validated,
and stored; defaults remain pinned to 0302 (Feb 2003) for now.

Technical:
- Introduce global "config.defaults.version" (eCmdHdlrGetWord).
- Parse YYMM with bounds on month; on invalid input emit an error and
  keep the last accepted baseline in messages.
- Add rsconf defaults: combined YYMM, year, month, and "explicit" flag.
- Initialize/reset these in `cnfSetDefaults()` and `resetConfigVariables()`
  using new macros pinned to 0302 to preserve historic behavior.
- Wire application in `glblDoneLoadCnf()` via configDefaultsVersionApply().
- Document the knob in rainerscript globals (available 8.2508.0+), with
  default noted as February 2003 compatibility baseline.

Non-technical:
This provides plumbing so new deployments can opt into modern defaults,
while existing systems can lock to legacy behavior. It improves
maintainability and a future path to safer, modern defaults without
surprising upgrades.

With the help of AI Agents: ChatGPT codex
@rgerhards rgerhards force-pushed the codex/add-global-config-for-version-override branch from f314c9d to 6c00387 Compare October 5, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant