Validate configuration values with a regex from the modules json - #663
Merged
Martin-Molinero merged 2 commits intoAug 28, 2026
Conversation
AlexCatarino
force-pushed
the
feature-ib-weekly-restart-time-validation
branch
from
August 14, 2026 22:52
390c81a to
ac5f578
Compare
AlexCatarino
force-pushed
the
feature-ib-weekly-restart-time-validation
branch
2 times, most recently
from
August 26, 2026 22:33
74b4f76 to
eefb56b
Compare
…json Adds an optional "input-regex" and "input-regex-message" to the module configurations, so a module describes the values it accepts instead of the CLI hard coding them. The regex is checked wherever a value enters the CLI: the command line options, the interactive prompts and the values read from the Lean config, which don't go through click and are validated by config_build. In interactive mode an unsupported value read from the Lean config is prompted for again, instead of aborting the deployment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
AlexCatarino
force-pushed
the
feature-ib-weekly-restart-time-validation
branch
from
August 26, 2026 23:00
eefb56b to
11b2e0d
Compare
…acing it The regex now wraps the type of the input method, so a path is still converted to a Path, a prompt with an integer input type still converts to an int and the choices are still checked, with the regex on top. It is ignored, with a debug message, for the choice and confirm input methods, whose prompts already describe the values they accept and can never be satisfied by a regex. An empty value isn't validated anymore, it means the user didn't provide one, which config_build reports as a missing option. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7iy3o91JamKGac8H88FMQ
Martin-Molinero
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Interactive Brokers doesn't support weekly restart times later than 23:30 UTC, but
--ib-weekly-restart-utc-timeaccepted any string. An invalid value was only rejected once the deployment reached the brokerage, after the project was compiled and the API call was made.Instead of hard coding that rule in the CLI, this adds generic regex validation to the modules json configuration schema, so any module can describe the values it accepts:
{ "id": "ib-weekly-restart-utc-time", "type": "input", "input-method": "prompt", "input-default": "21:00:00", "input-regex": "^(?:(?:[01][0-9]|2[0-2]):[0-5][0-9]:[0-5][0-9]|23:(?:[0-2][0-9]:[0-5][0-9]|30:00))$", "input-regex-message": "must be a UTC time in hh:mm:ss format, no later than 23:30:00" }input-regexis turned into aRegexParameterclick type, andinput-regex-messagedescribes the accepted values in the error. Both keys are optional, so configurations without them are unaffected, and CLI versions that don't know them ignore them.It covers the three ways a value reaches the config:
promptConfiguration.validate()called fromJsonModule.config_build()The command line option and the interactive prompt reject the value before the project is compiled. A value read from the Lean config aborts the deployment when running non-interactively, and is prompted for again when running interactively, so the user doesn't have to go and edit
lean.jsonby hand.The IB constraint itself ships in the modules json, it is not part of this PR. Until the json is republished with
input-regex, this PR is a no-op at runtime.Related Issue
N/A
Motivation and Context
Fail fast and locally with a clear message, instead of after a compile and a round trip, and keep a hand-edited
lean.jsonfrom carrying an unsupported value into a deployment. Keeping the rule in the modules json means the accepted values stay next to the configuration they belong to, and can be changed without a CLI release.Requires Documentation Change
No. The option metavar stays
TEXT, so the README is unchanged.How Has This Been Tested?
RegexParameterintests/test_click.py.tests/models/test_configuration.py, coveringvalidate(),get_input_type()and the click option type for the different input methods.tests/models/test_json_module.py, coveringconfig_build()rejecting a value read from the Lean config, prompting for a new one interactively, and accepting any value for a module which doesn't describe a regex.23:50:00and21:00, andlean live deploy --helpis unchanged.Types of changes
Checklist:
🤖 Generated with Claude Code