Skip to content

preview-netlify, preview-cloudflare: change detection lists lectures the pull request did not change #215

Closed

Description

@quantecon-services

Found while fact-checking the preview chapters of the user manual (#190, #213).

What happens

The "Changed Lectures" list in a preview comment, and the changed-files output, include lectures that the pull request never touched. Any lecture changed on the base branch after the pull request branched off is listed as modified.

Why

Both actions hand scripts/detect-changed-lectures.sh two commits:

  • BASE_SHA is github.event.pull_request.base.sha, the tip of the base branch (preview-netlify/action.yml:73, preview-cloudflare/action.yml:85).
  • HEAD_SHA is the pull request's head.

The script compares them with two dots (scripts/detect-changed-lectures.sh:33 and :56):

git diff --no-renames --name-status "${BASE_SHA}..${HEAD_SHA}"

A..B compares the two trees. A file that changed on the base branch after the pull request branched off differs between them, so it is listed. To list only what the pull request changed, the comparison must start from the merge base, which is what three dots give: git diff "${BASE_SHA}...${HEAD_SHA}".

Reproduction

A scratch repository where the pull request edits lectures/a.md, and main then edits lectures/d.md:

$ BASE_SHA=<main tip> HEAD_SHA=<pr tip> LECTURES_DIR=lectures bash scripts/detect-changed-lectures.sh
changed-files: lectures/a.md, lectures/d.md

$ git diff --no-renames --name-status <main tip>...<pr tip>
M	lectures/a.md

The fact-check also reproduced it on a depth-1 checkout of a simulated refs/pull/N/merge. There, three dots worked after the script's own git fetch of the two commits.

Proposed fix

  • Use ... in both git diff calls in scripts/detect-changed-lectures.sh.
  • Check that the merge base is reachable after the script's fetch in a shallow checkout. The fact-check found it was; if a checkout is ever too shallow, git diff A...B fails, and the script's || echo "" would silently list nothing. Deepening the fetch, or warning when git merge-base fails, would cover that.
  • Add a unit job to the harness that runs the script against a scratch repository like the one above. It needs no provider secrets, so it covers the one part of the preview actions the harness can run.

The user manual's preview chapters (#213) describe the current behaviour and link here. The fix PR updates them.

Activity

  1. added
    bug
    on Sep 28, 2026
  2. mmcky commented on Nov 4, 2026

    @mmcky
    Contributor

    From the 2026-10-06 codebase review (finding L4; record: .qe/dev/log/2026-10-06-codebase-review.md, #220).

    The base-tip half of the review's finding is this issue. The general half is not filed anywhere: scripts/detect-changed-lectures.sh hides every git failure. Both fetches end in 2>/dev/null || true (:26-27), and the name-status diff in 2>/dev/null || echo "" (:33). So any failure yields an empty list, and the preview comment loses its lecture links without a warning. #164 saw this in the field and fixed one cause (git ownership in containers), but left the swallowing in place.

    • Warn, with git's own message, whenever the diff fails, not only when the merge base is unreachable. This matters more once the three-dot diffs here and Phase 1 quick wins: bounded SHA fetches, concurrency-group fallback, paths-ignore in templates/ci.yml #147's shallow fetches land, since together they make an unreachable merge base more likely.
    • At :56, a git diff --quiet that errors returns 128, which the ! test reads as "changed": it fails open.
    • One option avoids the checkout altogether: the pull request files API, which the harness gate already uses (test-actions.yml:163-164). Its caveats: renames come back as renamed with the new path, results stop at 3,000 files, and the list can race a new push.
  3. added 7 commits that reference this issue on Nov 4, 2026
    a38a7bc
    76fbb9d
    780d6e3
    cf2b8b6
    49da3aa
    9770870
    dd19c8b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions