Skip to content

fix(change-detector): compare full push range - #44833

Merged
rusackas merged 3 commits into
apache:masterfrom
tarunchaudharydev:fix/change-detector-push-range
Nov 19, 2026
Merged

rusackas merged 3 commits into
apache:masterfrom
tarunchaudharydev:fix/change-detector-push-range

Conversation

@tarunchaudharydev

@tarunchaudharydev tarunchaudharydev commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Fix the change detector for push events containing multiple commits.

Previously, push events were compared only against the parent of the final commit. This could miss files changed in earlier commits within the same push.

This change uses the GitHub push event's before SHA and compares the full before...after range.

TESTING INSTRUCTIONS

  • pytest tests/unit_tests/scripts/change_detector_test.py
  • pre-commit run --files scripts/change_detector.py tests/unit_tests/scripts/change_detector_test.py
  • git diff --check

All change-detector tests pass.

ADDITIONAL INFORMATION

@bito-code-review

bito-code-review Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #87ae78

Actionable Suggestions - 0
Additional Suggestions - 2
  • scripts/change_detector.py - 1
    • Unhandled event file I/O · Line 202-203
      `get_push_before_sha` does `open()` + `json.load()` with no error handling on the push path that gates the whole CI matrix. A missing/unreadable/malformed `GITHUB_EVENT_PATH` file raises an unhandled exception and fails the build. Wrap in try/except and return `None` to fall back to the parent-based compare.
  • tests/unit_tests/scripts/change_detector_test.py - 1
    • Heavy import for trivial use · Line 18-18
      `from superset.utils import json` pulls in numpy, pandas, flask_babel, simplejson, and jsonpath_ng at test-collection time just to serialize a two-key dict. The stdlib `json` module (already used by `change_detector.py`) is sufficient and keeps this lightweight script test decoupled from the heavy app stack. Use `import json`.
Review Details
  • Files reviewed - 2 · Commit Range: 4d653e5..4d653e5
    • scripts/change_detector.py
    • tests/unit_tests/scripts/change_detector_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added the risk:ci-script PR modifies scripts that execute in CI (supply chain risk) label Sep 30, 2026
Comment thread scripts/change_detector.py Resolved
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. When a new branch is pushed, the GitHub event payload's before field is typically an all-zero SHA (0000000000000000000000000000000000000000). Since this string is truthy in Python, the current implementation attempts to use it in the compare URL, which results in an invalid request. To resolve this, you should check if the before_sha is a valid, non-zero SHA before using it.

Here is the corrected implementation for scripts/change_detector.py:

def get_push_before_sha() -> Optional[str]:
    event_path = os.getenv("GITHUB_EVENT_PATH")

    if not event_path:
        return None

    with open(event_path, encoding="utf-8") as event_file:
        event = json.load(event_file)

    before = event.get("before")
    if before and before != "0" * 40:
        return before
    return None

Would you like me to check the other comments on this PR and implement fixes for them as well?

scripts/change_detector.py

before = event.get("before")
    if before and before != "0" * 40:
        return before
    return None

@tarunchaudharydev
tarunchaudharydev force-pushed the fix/change-detector-push-range branch from 4d653e5 to 5e37b49 Compare September 30, 2026 20:24
Comment thread scripts/change_detector.py Resolved
Comment thread scripts/change_detector.py Resolved
@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.37%. Comparing base (e46b5e5) to head (3adcdc1).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #44833   +/-   ##
=======================================
  Coverage   85.37%   85.37%           
=======================================
  Files        3098     3098           
  Lines      213116   213116           
  Branches    50276    50276           
=======================================
+ Hits       181938   181951   +13     
+ Misses      27744    27738    -6     
+ Partials     3434     3427    -7     
Flag Coverage Δ
hive 34.03% <ø> (ø)
mysql 51.69% <ø> (ø)
postgres 51.72% <ø> (?)
presto 35.68% <ø> (ø)
python 88.17% <ø> (+0.01%) ⬆️
sqlite 51.40% <ø> (ø)
unit 83.36% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bito-code-review

bito-code-review Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #9758d3

Actionable Suggestions - 0
Additional Suggestions - 2
  • scripts/change_detector.py - 2
    • Unhandled event-file failure · Line 202-203
      `get_push_before_sha` opens `GITHUB_EVENT_PATH` and `json.load`s it with no error handling. If the env var is set but the file is missing or malformed, it raises instead of returning `None`, defeating the graceful fallback to the parent-SHA path in `fetch_changed_files_push`. Guard the read/parse and return `None` on failure.
    • Magic zero-SHA sentinel · Line 207-207
      `"0" * 40` is the GitHub zero-SHA sentinel marking a new branch's first push. Inline it as a named constant (e.g. `ZERO_SHA`) so the branch-detection rule is self-documenting and not re-derived by readers.
Review Details
  • Files reviewed - 2 · Commit Range: 5e37b49..5e37b49
    • scripts/change_detector.py
    • tests/unit_tests/scripts/change_detector_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@tarunchaudharydev
tarunchaudharydev force-pushed the fix/change-detector-push-range branch from 5e37b49 to d823fd7 Compare October 1, 2026 18:19
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Oct 1, 2026
@netlify

netlify Bot commented Oct 1, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit d823fd7
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6abea448e9ea6c00085b738e
😎 Deploy Preview https://deploy-preview-44833--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ab981e

Actionable Suggestions - 0
Additional Suggestions - 4
  • scripts/change_detector.py - 1
    • Unhandled event-file read error · Line 203-204
      `get_push_before_sha` gracefully returns None when `GITHUB_EVENT_PATH` is unset, but if the env var is set to a missing/unreadable file or malformed JSON, `open()`/`json.load()` raise OSError/JSONDecodeError and crash the CI script. Consider catching these and returning None for consistency with the defensive design.
  • tests/unit_tests/scripts/change_detector_test.py - 3
    • Heavy app import in unit test · Line 24-24
      `from superset.utils import json` drags the whole app stack (numpy, pandas, flask_babel, jsonpath_ng, superset.constants) into this standalone-script unit test at import time, slowing collection and coupling the test to the app. The tests only use `json.dumps` on plain dicts — stdlib `json` suffices.
    • Missing test docstrings · Line 192-192
      The four new test functions (lines 192, 219, 233, 247) have no docstrings. BITO adaptive rules 12148/15725 require every new test function to carry a docstring describing the scenario and expected outcome.
    • Missing type annotations in tests · Line 247-247
      New test code lacks required type annotations: `tmp_path` fixture param (line 247) is untyped, and local variables (`changed_files`, `event`, `fetch_mock`, `open_mock`, `output`, `written`) have no annotations. BITO adaptive rules 12101/13153 require explicit typing for fixture params and test-file locals.
Review Details
  • Files reviewed - 2 · Commit Range: d823fd7..d823fd7
    • scripts/change_detector.py
    • tests/unit_tests/scripts/change_detector_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 2, 2026

@sha174n sha174n 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.

LGTM.

github-issue-actions and others added 2 commits November 18, 2026 02:03
A forced push diffs against the merge base and can skip real changes, and a
zero before SHA (a new branch's first push) has no base to compare against.
Both now mark every group changed, like workflow_dispatch and schedule. The
event file is read once through get_push_event, and the multi-commit push test
is keyed by URL so it fails if the full push range is not used.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sadpandajoe

Copy link
Copy Markdown
Member

This PR has been quiet for a while. We'd like to help get it across the finish line, so we'll push updates here. Thanks for the contribution!

Following the review discussion, a forced push and a zero before SHA (a new branch's first push) now both mark every group as changed. When there is no event file or no before key (local or manual runs), the script keeps the old parent-only compare; changing that is beyond this PR. The event file is read without a try/except on purpose: if GitHub's event file can't be read, the job should fail loudly rather than quietly compare a narrower range.

Master's two languages tests also needed their fetch_changed_files_push stub updated for the new before_sha argument.

@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; push detection compares the full push range and treats forced or first-branch pushes as changes to every group.

Assessed commit: 3adcdc19b344

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Nov 18, 2026
@sadpandajoe
sadpandajoe requested a review from sha174n November 18, 2026 06:57

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @tarunchaudharydev, and @sadpandajoe for getting it over the line. LGTM!

@rusackas
rusackas merged commit 3565acb into apache:master Nov 19, 2026
72 checks passed
@tarunchaudharydev

Copy link
Copy Markdown
Contributor Author

Thank you, everyone, for the support and collaboration! I'm really happy to see this contribution merged. It's been a great experience working with the Apache Superset community.

I'm looking forward to contributing more, taking on bigger challenges, and becoming a more active part of this amazing community. I hope to continue learning from all of you and making meaningful contributions to Apache Superset.

Excited for what's ahead!

hainenber pushed a commit that referenced this pull request Nov 21, 2026
Co-authored-by: github-issue-actions <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:ci-script PR modifies scripts that execute in CI (supply chain risk) size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple issues with change_detector.py script

4 participants