Skip to content

fix: use lowercased key when validating windowsterminal.profileTemplate#40911

Open
Osamaali313 wants to merge 1 commit into
microsoft:masterfrom
Osamaali313:fix/validate-profiletemplate-key
Open

fix: use lowercased key when validating windowsterminal.profileTemplate#40911
Osamaali313 wants to merge 1 commit into
microsoft:masterfrom
Osamaali313:fix/validate-profiletemplate-key

Conversation

@Osamaali313

Copy link
Copy Markdown

Problem

read_config_keys lowercases option names when building its key dict:

keys[f'{section}.{key.lower()}'] = config[section][key]   # line 198

So a [windowsterminal] section with profileTemplate = ... is stored under windowsterminal.profiletemplate. But the validation block looks it up with the camelCase key:

if terminal_profile := config.get('windowsterminal.profileTemplate', None):   # line 455
    validate_mode(terminal_profile, [oct(0o660), oct(0o640)], 0, 0, 1024 * 1024)
    if not terminal_profile.startswith(USR_LIB_WSL):
        warning(...)

dict.get is case-sensitive, so this always returns None and the block never runs — the terminal profile template file's mode/size/location checks are silently skipped for every distribution validated. The valid-keys list (line 433) and every other config.get(...) in this function already use the lowercase form (oobe.command, shortcut.icon, windowsterminal.profiletemplate, …); line 455 was the lone outlier.

Reproduction

Using the real read_config_keys on the canonical config ([windowsterminal] / profileTemplate = /usr/lib/wsl/terminal.json, as written in the repo's own tests):

stored keys: ['windowsterminal.profiletemplate']
get('windowsterminal.profileTemplate') -> None   # block SKIPPED (bug)
get('windowsterminal.profiletemplate') -> '/usr/lib/wsl/terminal.json'   # block RUNS (fixed)

Fix

Look up the lowercase key at line 455 so the validation block executes. One-character change; behavior of all other keys is unchanged.

read_config_keys lowercases option names (line 198: key.lower()), so the stored key is 'windowsterminal.profiletemplate'. The validation block looked it up as 'windowsterminal.profileTemplate' (camelCase), which never matches, so the terminal profile template's mode/size/location checks silently never ran. Every other config.get() in this function and the valid-keys list already use the lowercase form.

Look up the lowercase key so the validation block executes.
@Osamaali313 Osamaali313 requested a review from a team as a code owner June 25, 2026 19:56
Copilot AI review requested due to automatic review settings June 25, 2026 19:56

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants