Skip to content

Fix two diagnostic bugs in validate-modern.py#40418

Merged
benhillis merged 2 commits intomasterfrom
copilot/fix-validate-modern-python-bugs
May 7, 2026
Merged

Fix two diagnostic bugs in validate-modern.py#40418
benhillis merged 2 commits intomasterfrom
copilot/fix-validate-modern-python-bugs

Conversation

@benhillis
Copy link
Copy Markdown
Member

Fix two bugs in distributions/validate-modern.py.

Bug 1: missing f-string interpolation

In read_tar(), the size-too-big error printed the literal text (info.size) instead of the actual byte count:

error(node, f'file: ""{path}"" is too big (info.size), max: {max_size}')

Fixed to ({info.size}) so the message reports the offending size.

Bug 2: variable shadowing in validate_config()

The function took path: str as input, then immediately did:

_, path = get_tar_file(tar, path, follow_symlink=True)

This overwrote the input parameter with the resolved tar path (which can be None if the file isn't found). The subsequent if path is None: error(node, f'File ""{file}"" not found in tar') couldn't print the original requested path, and downstream messages ("Found unexpected_keys in...", "Found valid keys in...") logged the resolved-symlink path rather than the user-facing config name.

Renamed the inner variable to real_path so the original path is preserved for diagnostics and real_path is used for tar.extractfile().

Risk

Tooling-only script, no runtime impact. Improves diagnostic output of the distribution validator.

1. Line 394: f-string missing braces around info.size - was printing the
   literal text '(info.size)' instead of the actual file size value.
   Fix: Change (info.size) to ({info.size}).

2. Line 414: validate_config reassigned its 'path' parameter to the
   resolved tar member path, then printed the (now-None) path in the
   not-found error. Renamed the local to 'real_path' so the error
   message references the original input path the caller asked for.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benhillis benhillis requested a review from a team as a code owner May 5, 2026 00:56
Copilot AI review requested due to automatic review settings May 5, 2026 00:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the tar-based distribution validator in distributions/validate-modern.py to improve diagnostic output during modern distribution validation. It targets two small validator bugs in the distributions tooling path used by the repository’s distribution-check workflow.

Changes:

  • Fixes the oversized-file diagnostic so it prints the actual offending file size.
  • Refactors validate_config() to separate the requested config path from the resolved tar member path.
  • Adjusts config-file lookup and extraction to use the resolved tar path after symlink resolution.

Comment thread distributions/validate-modern.py Outdated
The unexpected_keys error and 'Found valid keys' log were still using the resolved tar member path instead of the caller-supplied config path, so symlinked configs (e.g. /etc/wsl.conf -> /etc/wsl.conf.real) would still report the symlink target rather than the user-facing config name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benhillis benhillis merged commit 4e547da into master May 7, 2026
12 checks passed
@benhillis benhillis deleted the copilot/fix-validate-modern-python-bugs branch May 7, 2026 23:14
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.

3 participants