Repository navigation
Conversation
At startup, --dynamic-config-yaml/--dynamic-config-json apply every key in the file as an argparse default, so the file can hold any router flag, such as log_stats. The watcher then builds DynamicRouterConfig(**config) from the same file every 10 seconds. That constructor raises TypeError for any key that is not a reloadable field, and the watcher only logs a warning. So a file with one startup-only flag silently disables hot reload for every field. Build the config from the file's keys instead: - Reloadable fields are applied. - Router flags that are not fields are ignored (debug-logged). - Any other key is most likely a typo and raises ValueError, so the watcher keeps the running configuration rather than resetting the misspelled field to its default. Flags are recognized from the same argparse parser used at startup; parse_args now delegates to build_parser for this. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EkWp1KKx8oCX8JA3mXdkVJ Signed-off-by: Mazyad Alabduljaleel <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request refactors the dynamic configuration loading to handle startup-only flags gracefully and reject unknown keys during reloads. It extracts the command-line parser creation into a standalone build_parser function to identify valid flags, introduces from_config_dict to filter these flags, and adds corresponding unit tests. Feedback is provided to specify encoding='utf-8' when opening the JSON configuration file to avoid potential UnicodeDecodeError issues on platforms where the default encoding is not UTF-8.
| @staticmethod | ||
| def from_json(json_path: str) -> "DynamicRouterConfig": | ||
| with open(json_path, "r") as f: | ||
| config = json.load(f) |
There was a problem hiding this comment.
When opening the JSON configuration file, the encoding parameter is not specified. On platforms where the default system encoding is not UTF-8 (such as Windows), this can lead to UnicodeDecodeError if the file contains non-ASCII characters.\n\nTo ensure consistency with other file-loading methods in the codebase (e.g., in parser.py and yaml_utils.py), please specify encoding=\"utf-8\" when opening the file:\n\npython\n with open(json_path, \"r\", encoding=\"utf-8\") as f:\n
There was a problem hiding this comment.
Applied in 65d25c6: the JSON config is now read as UTF-8, like the YAML loader and parser.py.
Address review feedback: match the YAML loader and parser.py, which already open config files as UTF-8. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EkWp1KKx8oCX8JA3mXdkVJ Signed-off-by: Mazyad Alabduljaleel <[email protected]>
|
A note on #1167, which also touches |
FIX #1232
The dynamic config file can hold any router flag at startup, but the watcher built
DynamicRouterConfig(**config)from it. Any startup-only key (for examplelog_stats) then raisedTypeErroron every tick, which silently disabled hot reload.from_yamlandfrom_jsonnow classify the file's keys:parse_argsnow delegates to a newbuild_parser.ValueError, so the watcher keeps the running configuration instead of silently resetting a misspelled field to its default.The
k8s_*default mismatch described in #1232 is deliberately left out to keep this focused. Happy to add it here or in a follow-up.Testing:
log_statsandengine_stats_intervalloads, and a JSON file with the typocallbackis rejected. Both tests fail on main withTypeErrorand pass with this change.-swhen doinggit commit[Bugfix],[Feat], and[CI].🤖 Generated with Claude Code
https://claude.ai/code/session_01EkWp1KKx8oCX8JA3mXdkVJ