Skip to content

feat: Check supported static binary builds version before attempting download - #151

Merged
2bndy5 merged 6 commits into
mainfrom
copilot/fix-version-check-error-message
May 9, 2026
Merged

feat: Check supported static binary builds version before attempting download#151
2bndy5 merged 6 commits into
mainfrom
copilot/fix-version-check-error-message

Conversation

Copilot AI commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Requesting an unsupported version produces an opaque OSError from a failed HTTP download. This adds an early validation that raises a clear ValueError instead, and restores coverage of the OSError path with a dedicated test.

Changes

  • clang_tools/__init__.py: Added MIN_VERSION = 11 and MAX_VERSION = 22 constants (matching the supported range in the README).
  • clang_tools/install.py: Imports MIN_VERSION and MAX_VERSION from the package __init__. Added a version range check in install_clang_tools() that raises a clear ValueError for unsupported versions:
if version.info[0] not in range(MIN_VERSION, MAX_VERSION + 1):
    raise ValueError(
        f"{version.info[0]} is not available in static binary builds. "
        f"Only versions {MIN_VERSION} to {MAX_VERSION} are available."
    )
  • tests/test_install.py: Updated test_path_warning to exercise the new ValueError. Added test_install_tool_download_error which monkeypatches binary_repo to an invalid URL, causing download_file to return None and install_tool to raise OSError("Failed to download ..."), restoring code coverage of that path.
Original prompt

This section details on the original issue you should resolve

<issue_title>Check version requested against available static builds</issue_title>
<issue_description>If trying to install a version that is not available in our static binary builds, I get the error:

  File "/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/clang_tools/install.py", line 120, in install_tool
    raise OSError(f"Failed to download {bin_name} from {bin_url}")
OSError: Failed to download clang-format-9_linux-amd64 from https://github.com/cpp-linter/clang-tools-static-binaries/releases/download/master-63858060/clang-format-9_linux-amd64

A better error message, specific to this case, would be nice:

if version.major not in range(min_supported_version, max_supported_version + 1):
    raise ValueError(
        f"{version.major} is not available in static binary builds. "
        f"Only versions {min_supported_version} to {max_supported_version} are available."
    )

</issue_description>

<agent_instructions>Please implement this request</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@github-actions github-actions Bot added the bug Something isn't working label Mar 9, 2026
Copilot AI changed the title [WIP] Fix error message for unavailable static build versions Check version against supported static binary builds before attempting download Mar 9, 2026
@codecov

codecov Bot commented Mar 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.87%. Comparing base (bfe8ede) to head (c6449a6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   95.71%   95.87%   +0.15%     
==========================================
  Files           9        9              
  Lines         327      339      +12     
==========================================
+ Hits          313      325      +12     
  Misses         14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread clang_tools/install.py Outdated
Comment thread tests/test_install.py Outdated
Comment thread tests/test_install.py Outdated
@sonarqubecloud

Copy link
Copy Markdown

@shenxianpeng shenxianpeng added enhancement New feature or request and removed bug Something isn't working labels Mar 10, 2026
@shenxianpeng shenxianpeng changed the title Check version against supported static binary builds before attempting download feat: Check supported static binary builds version before attempting download Mar 10, 2026
@shenxianpeng
shenxianpeng marked this pull request as ready for review March 10, 2026 07:08
@shenxianpeng
shenxianpeng requested a review from 2bndy5 March 10, 2026 07:09
Comment thread tests/test_install.py Outdated
@2bndy5

2bndy5 commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

The CI failures seem to be related to downloads from PyPI, not our static binaries. More specifically, the failures seems to use system python instead of a venv

2bndy5 added a commit that referenced this pull request Mar 17, 2026
- [x] remove unused release-drafter config
- [x] update permissions for jobs that invoke reusable release-drafter workflows
- [x] switch labeler workflow to use separate reusable workflow

refs:
- cpp-linter/.github#71
- cpp-linter/.github#74

- supersedes and closes #151
@2bndy5 2bndy5 closed this in 6b7e665 Mar 17, 2026
@2bndy5

2bndy5 commented May 9, 2026

Copy link
Copy Markdown
Contributor

I think this was closed by mistake. I accidentally referenced this PR in #154 (I meant to reference #153). So, when #154 was merged, this got closed also.

@2bndy5 2bndy5 reopened this May 9, 2026
@2bndy5
2bndy5 force-pushed the copilot/fix-version-check-error-message branch from b95f28d to 229ab4c Compare May 9, 2026 05:43
Copilot AI requested a review from 2bndy5 May 9, 2026 05:50
Copilot finished work on behalf of 2bndy5 May 9, 2026 05:50
Comment thread clang_tools/install.py
Copilot finished work on behalf of 2bndy5 May 9, 2026 06:29
Copilot AI requested a review from 2bndy5 May 9, 2026 06:29
@sonarqubecloud

sonarqubecloud Bot commented May 9, 2026

Copy link
Copy Markdown

@2bndy5
2bndy5 merged commit a28d4fa into main May 9, 2026
70 checks passed
@2bndy5
2bndy5 deleted the copilot/fix-version-check-error-message branch May 9, 2026 07:31
@shenxianpeng shenxianpeng added the minor A minor version bump label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor A minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check version requested against available static builds

3 participants