Skip to content

Fix regression: restore config validate() call in config.py#2690

Merged
maobaolong merged 8 commits intoLMCache:devfrom
hlin99:regression_validate
Mar 15, 2026
Merged

Fix regression: restore config validate() call in config.py#2690
maobaolong merged 8 commits intoLMCache:devfrom
hlin99:regression_validate

Conversation

@hlin99
Copy link
Copy Markdown
Contributor

@hlin99 hlin99 commented Mar 4, 2026

Fix regression(#2510): Add _update_config_from_env to namespace_extras The _validate_config function at line 504 was not being called after commit 3d88cee because the custom _update_config_from_env method was removed from namespace_extras, causing the config to use the base implementation which doesn't call validate().

This commit:

  • Adds _update_config_from_env back to namespace_extras
  • Updates the method to use the new _resolve_config_aliases signature
  • Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk for PD mode) is properly executed when configs are updated from env vars.

  • [ Y ] this PR contains unit tests

Fix regression: Add _update_config_from_env to namespace_extras
The _validate_config function at line 504 was not being called after
commit 3d88cee because the custom _update_config_from_env method was
removed from namespace_extras, causing the config to use the base
implementation which doesn't call validate().

This commit:
- Adds _update_config_from_env back to namespace_extras
- Updates the method to use the new _resolve_config_aliases signature
- Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk
for PD mode) is properly executed when configs are updated from env vars.

Signed-off-by: Tony Lin <tony.lin@intel.com>
@hlin99
Copy link
Copy Markdown
Contributor Author

hlin99 commented Mar 4, 2026

hi @maobaolong would you like to take a look? the regression seems to be introduced by 3d88cee, but i'm not 100% sure if this is intentional. please double confirm. thanks.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 a regression that prevented configuration validation from executing when settings were loaded from environment variables. By restoring the custom _update_config_from_env method and updating its internal call to _resolve_config_aliases, the system now correctly applies validation logic, such as auto-setting save_unfull_chunk for PD mode, ensuring consistent and reliable configuration behavior. A dedicated regression test has been added to safeguard against this issue recurring.

Highlights

  • Restored Config Validation: The _update_config_from_env method has been re-added to namespace_extras, ensuring that the validate() method is correctly called when configurations are updated from environment variables.
  • Updated Signature: The _update_config_from_env method now uses the new signature for _resolve_config_aliases, passing explicit configuration definitions and aliases.
  • Regression Test Added: A new unit test test_update_config_from_env_calls_validate has been introduced to specifically verify that config validation occurs when updating from environment variables, preventing future regressions.

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

Changelog
  • lmcache/v1/config.py
    • Updated the call to _resolve_config_aliases to include _CONFIG_DEFINITIONS, _CONFIG_ALIASES, and _DEPRECATED_CONFIGS as arguments.
    • Ensured the _user_set_keys attribute is initialized if it doesn't exist.
    • Added logic to mark configuration keys as user-set when their values are updated from environment variables.
    • Re-added _update_config_from_env to the namespace_extras dictionary.
  • tests/v1/test_config.py
    • Introduced test_update_config_from_env_calls_validate to confirm that validate() is invoked during environment variable configuration updates, specifically checking the save_unfull_chunk behavior in PD mode.
Activity
  • No human activity has been recorded on this pull request yet.
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
Copy Markdown
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 effectively addresses a regression where the validate() method was not being called when updating configuration from environment variables. The fix correctly restores the custom _update_config_from_env method to the LMCacheEngineConfig's namespace and updates its implementation to be consistent with recent changes in the base configuration class. The addition of a regression test is excellent, as it specifically verifies that the validation logic is now triggered as expected. I have one suggestion to improve the maintainability of the new test case.

Comment thread tests/v1/test_config.py
Comment on lines +694 to +717
# Set up environment for PD mode which requires validation
os.environ["LMCACHE_ENABLE_PD"] = "true"
os.environ["LMCACHE_PD_ROLE"] = "sender"
os.environ["LMCACHE_PD_BUFFER_SIZE"] = "1024"
os.environ["LMCACHE_PD_BUFFER_DEVICE"] = "cpu"
os.environ["LMCACHE_SAVE_UNFULL_CHUNK"] = "false"

try:
# Create a config and update from env
config = LMCacheEngineConfig.from_defaults()
config.update_config_from_env()

# If validate() was called, save_unfull_chunk should be auto-set to True
# because PD mode requires it (see line 558-564 in config.py)
assert config.save_unfull_chunk is True, (
"validate() was not called - save_unfull_chunk should be True for PD mode"
)
finally:
# Clean up environment
del os.environ["LMCACHE_ENABLE_PD"]
del os.environ["LMCACHE_PD_ROLE"]
del os.environ["LMCACHE_PD_BUFFER_SIZE"]
del os.environ["LMCACHE_PD_BUFFER_DEVICE"]
del os.environ["LMCACHE_SAVE_UNFULL_CHUNK"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The setup and cleanup of environment variables in this test are a bit repetitive. To improve maintainability and reduce duplication, you could define the environment variables in a dictionary and then iterate over it for both setting them up and tearing them down. This would make it easier to add or remove variables in the future, as you'd only need to change them in one place. Using os.environ.pop() in the cleanup is also slightly more robust than del.

    # Set up environment for PD mode which requires validation
    env_vars = {
        "LMCACHE_ENABLE_PD": "true",
        "LMCACHE_PD_ROLE": "sender",
        "LMCACHE_PD_BUFFER_SIZE": "1024",
        "LMCACHE_PD_BUFFER_DEVICE": "cpu",
        "LMCACHE_SAVE_UNFULL_CHUNK": "false",
    }
    for key, value in env_vars.items():
        os.environ[key] = value

    try:
        # Create a config and update from env
        config = LMCacheEngineConfig.from_defaults()
        config.update_config_from_env()

        # If validate() was called, save_unfull_chunk should be auto-set to True
        # because PD mode requires it (see line 558-564 in config.py)
        assert config.save_unfull_chunk is True, (
            "validate() was not called - save_unfull_chunk should be True for PD mode"
        )
    finally:
        # Clean up environment
        for key in env_vars:
            os.environ.pop(key, None)

Copy link
Copy Markdown
Contributor

@sammshen sammshen left a comment

Choose a reason for hiding this comment

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

lgtm

@hlin99
Copy link
Copy Markdown
Contributor Author

hlin99 commented Mar 9, 2026

hi @maobaolong , just make sure you're aware of this PR... if you have other solutions, please comments. thx.

Copy link
Copy Markdown
Collaborator

@maobaolong maobaolong left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your fix.

@maobaolong maobaolong enabled auto-merge (squash) March 14, 2026 02:28
@github-actions github-actions Bot added the full Run comprehensive tests on this PR label Mar 14, 2026
@maobaolong maobaolong merged commit dedea50 into LMCache:dev Mar 15, 2026
25 of 28 checks passed
@hlin99 hlin99 deleted the regression_validate branch March 15, 2026 05:40
hyunyul-XCENA pushed a commit to xcena-dev/LMCache that referenced this pull request Mar 20, 2026
…2690)

Fix regression: Add _update_config_from_env to namespace_extras
The _validate_config function at line 504 was not being called after
commit 3d88cee because the custom _update_config_from_env method was
removed from namespace_extras, causing the config to use the base
implementation which doesn't call validate().

This commit:
- Adds _update_config_from_env back to namespace_extras
- Updates the method to use the new _resolve_config_aliases signature
- Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk
for PD mode) is properly executed when configs are updated from env vars.

Signed-off-by: Tony Lin <tony.lin@intel.com>
realAaronWu pushed a commit to realAaronWu/LMCache that referenced this pull request Mar 20, 2026
…2690)

Fix regression: Add _update_config_from_env to namespace_extras
The _validate_config function at line 504 was not being called after
commit 3d88cee because the custom _update_config_from_env method was
removed from namespace_extras, causing the config to use the base
implementation which doesn't call validate().

This commit:
- Adds _update_config_from_env back to namespace_extras
- Updates the method to use the new _resolve_config_aliases signature
- Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk
for PD mode) is properly executed when configs are updated from env vars.

Signed-off-by: Tony Lin <tony.lin@intel.com>
Signed-off-by: Aaron Wu <aaron.wu@dell.com>
deng451e pushed a commit to deng451e/LMCache that referenced this pull request Mar 25, 2026
…2690)

Fix regression: Add _update_config_from_env to namespace_extras
The _validate_config function at line 504 was not being called after
commit 3d88cee because the custom _update_config_from_env method was
removed from namespace_extras, causing the config to use the base
implementation which doesn't call validate().

This commit:
- Adds _update_config_from_env back to namespace_extras
- Updates the method to use the new _resolve_config_aliases signature
- Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk
for PD mode) is properly executed when configs are updated from env vars.

Signed-off-by: Tony Lin <tony.lin@intel.com>
deng451e pushed a commit to deng451e/LMCache that referenced this pull request Mar 27, 2026
…2690)

Fix regression: Add _update_config_from_env to namespace_extras
The _validate_config function at line 504 was not being called after
commit 3d88cee because the custom _update_config_from_env method was
removed from namespace_extras, causing the config to use the base
implementation which doesn't call validate().

This commit:
- Adds _update_config_from_env back to namespace_extras
- Updates the method to use the new _resolve_config_aliases signature
- Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk
for PD mode) is properly executed when configs are updated from env vars.

Signed-off-by: Tony Lin <tony.lin@intel.com>
jooho-XCENA pushed a commit to xcena-dev/LMCache that referenced this pull request Apr 2, 2026
…2690)

Fix regression: Add _update_config_from_env to namespace_extras
The _validate_config function at line 504 was not being called after
commit 3d88cee because the custom _update_config_from_env method was
removed from namespace_extras, causing the config to use the base
implementation which doesn't call validate().

This commit:
- Adds _update_config_from_env back to namespace_extras
- Updates the method to use the new _resolve_config_aliases signature
- Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk
for PD mode) is properly executed when configs are updated from env vars.

Signed-off-by: Tony Lin <tony.lin@intel.com>
jooho-XCENA pushed a commit to xcena-dev/LMCache that referenced this pull request Apr 2, 2026
…2690)

Fix regression: Add _update_config_from_env to namespace_extras
The _validate_config function at line 504 was not being called after
commit 3d88cee because the custom _update_config_from_env method was
removed from namespace_extras, causing the config to use the base
implementation which doesn't call validate().

This commit:
- Adds _update_config_from_env back to namespace_extras
- Updates the method to use the new _resolve_config_aliases signature
- Adds a regression test to verify validate() is called

The fix ensures that validation logic (like auto-setting save_unfull_chunk
for PD mode) is properly executed when configs are updated from env vars.

Signed-off-by: Tony Lin <tony.lin@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full Run comprehensive tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants