Skip to content

fix(check): check named file from GitHub blob URLs instead of falling back silently - #226

Merged
patrickballard merged 6 commits into
wheelgap:mainfrom
dev-burnern:fix/blob-url-check-named-file
Nov 22, 2026
Merged

patrickballard merged 6 commits into
wheelgap:mainfrom
dev-burnern:fix/blob-url-check-named-file

Conversation

@dev-burnern

Copy link
Copy Markdown
Contributor

Closes #220

What this changes

  • site/check/check-logic.mjs:
    • parseRepo() now returns file (decoded file path) for GitHub /blob/REF/FILE URLs while keeping dir unchanged, and file: null for /tree/ URLs and owner/name inputs.
    • Adds isReadableFile(path) (*.txt, *.in, pyproject.toml) and pickRequestedFile(lockfiles, requested, inTree, dir) to resolve an explicitly named file (from a /blob/ URL or ?lock= query): checks it directly if listed, adds it to plan.lockfiles and checks it if present in the repo tree and readable, or falls back to the automatic pick with a clear notice (<file> isn't a file this page reads. Checked <fallback> instead.).
  • site/check/worker.mjs & site/check/check.mjs:
    • Passes the requested file path (query?.lockfile || repo.file) to load(), checks whether it exists in the repo tree (fileInTree), and uses pickRequestedFile() in onLoaded().
    • Shows any fallback notice in the verdict card's #alerts (and in noLockfile() when the repo has no readable fallback), clearing it if the visitor picks another file in the dropdown.
    • Preserves ?lock=<file> across toQuery() / fromQuery() so "Copy link to this result" reopens the same check.
  • tests/site/check-logic.test.mjs & tests/site/check-page.test.mjs:
    • Covers parseRepo() file extraction (nested path, root file, %20 names, tree URLs, owner/name), toQuery()/fromQuery() round-trip for requirements/default.txt, and onLoaded() for an unlisted requirements/default.txt, a listed backend/uv.lock, and an unreadable README.md.

AI tools used (if any): Antigravity (Gemini)

Checklist

  • node --check site/check/*.mjs passes
  • node --test tests/site/check-logic.test.mjs tests/site/check-page.test.mjs passes (37/37)

dev-burnern and others added 2 commits November 22, 2026 16:38
…named lockfiles

- The named file is added after the repo's own files, so the badge's automatic
  pick is unchanged and its link keeps lock= (it checked pyproject.toml again).
- The fallback notice says only why; the verdict names the file it actually
  checked, which can change after a tool-settings-only pyproject.toml.
- A named uv.lock/poetry.lock/... in a folder plan() skips, and names wheelgap
  reads (pylock.*.toml, *.py.lock, requirements*.lock), are checked instead of
  refused; offline is set from the lockfile name.
- With a truncated file list, a named file is fetched rather than called missing.
- Tests for pickRequestedFile and isReadableFile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Contributor

Thanks, @dev-burnern! Pulling the choice into a pure pickRequestedFile() makes the three cases easy to follow, and rejecting .. in file just as dir does keeps the raw URLs safe.

We've made these changes so it can go in:

  • The README badge keeps the right file. The named file was put first in the list, so the badge's automatic pick became that file and the badge link dropped lock=. Clicking it checked pyproject.toml again, which is the Repo checker: a link to one file (…/blob/main/requirements/default.txt) checks a different file #220 error. It's now added at the end.
  • The notice names the file actually checked. After a fallback to a pyproject.toml with only tool settings, the page moves on to the next file, but the notice still said "Checked pyproject.toml instead". The notice now holds only the reason, and the verdict adds the file it ended up checking.
  • Named lockfiles are read, not refused. A link to examples/app/uv.lock (a folder plan() skips), or to names wheelgap reads such as pylock.dev.toml, script.py.lock and requirements-dev.lock, said "isn't a file this page reads". Now it checks them, with offline set from the lockfile name.
  • A truncated file list no longer calls a named file "not found". The page fetches it anyway.
  • Added direct tests for pickRequestedFile() and isReadableFile(), plus the badge and skipped-folder cases in check-page.test.mjs.

It'll merge once a final review passes.

(Review assisted by Claude.)

- Files a link named are marked `added`, and the badge's default comes
  from the repo's own list, so a repo whose only file was named by the
  link keeps lock= in its badge.
- The "isn't a file this page reads" notice also shows when the
  fallback file can't be read, and when it needs PyPI lookups.
- ?lock= rejects empty, "." and leading-slash segments, as parseRepo()
  does for blob paths.
- *.txt / *.in match case-sensitively, as wheelgap's file_kind does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Contributor

Thanks again, @dev-burnern! The final review found two more cases, so we've made these changes so it can go in:

  • The badge keeps lock= when the named file is the repo's only one. If a blob link named requirements/base.txt and the repo had no other file the page lists, that file became the "default", so the badge link dropped lock= and reopened as "No lockfile found". Files a link names are now marked added, and the badge's default comes from the repo's own list.
  • The fallback notice shows in every outcome. It now also appears when the fallback file can't be read, and when the fallback needs PyPI lookups. Before, those paths dropped it silently, which is the problem Repo checker: a link to one file (…/blob/main/requirements/default.txt) checks a different file #220 describes.
  • ?lock= is checked like a blob path: empty, . and leading-slash segments are rejected, not just ...
  • *.txt and *.in match case-sensitively, as wheelgap's own file_kind does.

It'll merge once a final review passes.

(Review assisted by Claude.)

@patrickballard

Copy link
Copy Markdown
Contributor

Thanks again, @dev-burnern, this is very close. The review of our last round turned up two more cases, and since we've already been round twice, Patrick will take a final look and merge it himself:

  • isReadableFile() accepts some lock names the driver doesn't treat as locks. A blob link to pylock.dev.toml or uv-py312.lock is checked as a lookup file, because driver.py decides "offline" from the exact names in OFFLINE. A Python the lock leaves out then shows false gaps instead of being listed as outside the lock.
  • *.py.lock is accepted, but the pinned wheelgap 0.13.0 can't read it, so script.py.lock ends in "couldn't read" rather than the "isn't a file this page reads" fallback Repo checker: a link to one file (…/blob/main/requirements/default.txt) checks a different file #220 asks for.

(Review assisted by Claude.)

patrickballard and others added 3 commits November 22, 2026 11:11
driver.py decided offline from the exact names in OFFLINE, so a blob link to pylock.dev.toml or uv-py312.lock was checked as a lookups file and a Python its lock leaves out showed false gaps instead of being listed as outside the lock. needs(), check() and plan() now decide by sources.file_kind's reader (OFFLINE_KINDS), and the page mirrors wheelgap 0.13.0's file_kind in fileKind() for isReadableFile() and the added file's offline flag. *.py.lock is refused with the fallback notice, since 0.13.0 can't read it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d one

The badge test still matched the old line, pickLockfile(state.plan.lockfiles, null). Since 7ef3656 renderNext() leaves out files a blob link or ?lock= added (added: true), so the badge for such a file keeps lock= and a visit with the repo alone picks what it always would. The code is right; the test now matches it and checks the three cases: an added file beside the repo's own, an added file that's the only one, and the repo's own default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts with wheelgap#227 resolved by keeping both: the imports are the union (inputHint and pickRequestedFile in check.mjs; inputHint, pickRequestedFile, isReadableFile and fileKind in the logic tests), and both PRs' appended tests are kept. start() keeps wheelgap#227's inputError reset first and wheelgap#226's fileNotice reset and named file; parseRepo() keeps wheelgap#227's dotted-owner refusal with wheelgap#226's file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard
patrickballard merged commit aa50658 into wheelgap:main Nov 22, 2026
1 check passed
patrickballard added a commit to benjibunbun/tracker that referenced this pull request Nov 22, 2026
One conflict, in tests/site/check-page.test.mjs, where both sides appended tests: both kept (wheelgap#223's resultPage tests, then wheelgap#226's blob-link and wheelgap#227's hint tests). check.mjs, check-logic.mjs and driver.py merged without conflict: onResult() keeps the all-private fallback with its folder filter before wheelgap#226's fallback notice, renderVerdict() has both the private-pyproject verdict and the named-file notice, and driver.py has private_count with the reader-based offline check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patrickballard added a commit to dev-burnern/tracker that referenced this pull request Nov 22, 2026
Resolved with wheelgap#226 and wheelgap#223 as the second review set out. plan() entries are {path, offline: _reads_offline(p)} with other: True for requirements files under other names. pickRequestedFile()'s own pick (no file named, or one that can't be checked) is now autoPick()'s and passes its choose through; a named or added file has choose null. onLoaded() takes wheelgap#226's picked/lockfiles/fileNotice, shows noLockfile only with neither a lock nor a choice, sets the targets, then asks with chooseFile(), which shows the fallback notice. renderSetup keeps the Choose a file option and clears fileNotice on change. The badge default is autoPick() over the files a link didn't add. wheelgap#223's private-pyproject folder filter runs before autoPick(), so covered other-named files are never offered or checked. Tests: both sides kept, harnesses given pickRequestedFile and privatePyprojectReason, pickRequestedFile results now carry choose, and new cases for these interactions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patrickballard added a commit to dev-burnern/tracker that referenced this pull request Nov 22, 2026
Resolved with wheelgap#226 and wheelgap#229 as the second review set out. The page state and onLoaded() take both fileInTree and projectName, and the worker returns both; onLoaded() keeps wheelgap#226's picked/fileNotice and wheelgap#229's chooser, with the targets set before the no-lockfile answer. noLockfile() puts wheelgap#226's notice first on wheelgap#228's text, without the Run uvx wheelgap sentence; showPackageFallback() shows the notice first in #alerts; onResult()'s error branch keeps wheelgap#226's notice in the status, then the package fallback. The worker reads the project name with metadataFiles() over the files that aren't wheelgap#229's other-named requirements files. chooseFile() also offers the --deps command when the repo names its package. Tests: both sides kept; wheelgap#228's harnesses given pickRequestedFile, privatePyprojectReason, autoPick and chooseFile; its status assertion matches main's capitalised Wheelgap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patrickballard added a commit to dev-burnern/tracker that referenced this pull request Nov 22, 2026
Resolved as the second review set out. renderVerdict() sets isClean, toggles the card, hides the README badge offer unless the result is clean with no private-index packages, then uses wheelgap#223's verdict ternary (private pyproject, every Python left out, verdictText). renderNext() keeps wheelgap#225's Keep it green condition (r.private empty) with main's badge default from wheelgap#226/wheelgap#229 untouched. The copy-share handler, with the private count that drops the ✓, sits beside main's copy-prompt handler, which passes state.lab (wheelgap#231). Imports are the union, with shareText. Tests: both sides kept; wheelgap#225's renderVerdict/renderNext harness given autoPick and privatePyprojectReason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Contributor

Merged, thanks @dev-burnern! We pushed a few fixes to your branch before merging; the commits say what and why.

(Posted with help from Claude.)

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.

Repo checker: a link to one file (…/blob/main/requirements/default.txt) checks a different file

2 participants