Skip to content

fix(scanDiff): read commitConfig per push so --config block rules apply - #1891

Merged
jescalada merged 3 commits into
mainfrom
fix/scandiff-config-timing
Nov 19, 2026
Merged

jescalada merged 3 commits into
mainfrom
fix/scandiff-config-timing

Conversation

@goldensyntax

Copy link
Copy Markdown
Contributor

Description

scanDiff read its configuration at module import time:

// src/proxy/processors/push-action/scanDiff.ts (before)
const commitConfig = getCommitConfig();
const privateOrganizations = getPrivateOrganizations();

index.ts imports the proxy (and therefore scanDiff) before it applies --config, so
scanDiff captured only the empty default commitConfig.diff.block lists and never saw
the configured rules. Pushes that should have been blocked were sent to approval instead,
with no error.

This PR moves the two reads into combineMatches, so they run per push, after the config
has been loaded:

// after
const combineMatches = (organization: string) => {
  const commitConfig = getCommitConfig();
  const privateOrganizations = getPrivateOrganizations();
  // ... existing body unchanged
};

As suggested by @kriswest, I also checked checkMessages and checkAuthorEmails while
diagnosing this issue. They do not have this problem, as both already read config inside
their per-push functions. This change only changes the config read timing in scanDiff,
ensuring it reads the config per push.

Test

This PR introduces a regression test (test/processors/scanDiff.configTiming.test.ts) that
checks a block rule from a config loaded after scanDiff is imported is still enforced,
which is the exact scenario that was failing.

It configures a blocked literal, runs scanDiff over a diff that adds that literal, and
expects the push to be blocked. The config is loaded after the import on purpose, to mirror
--config being applied after the module loads. The test fails on the old code and passes
with this fix.

Related Issue

Resolves #1874

Checklist

General

Documentation

  • Documentation has been added/updated for any new features

Configuration

  • If configuration schema (config.schema.json) was modified:
    • TypeScript types regenerated (npm run generate-config-types)
    • Schema reference docs regenerated (npm run gen-schema-doc)

Tests

  • Tests have been added/updated for new functionality
  • Unit tests pass (npm test)
  • Linting and formatting pass (npm run lint and npm run format:check)
  • Type checks pass (npm run check-types)

scanDiff read getCommitConfig() and getPrivateOrganizations() at module import time,
before index.ts applies --config. It therefore kept the empty default block lists and
never enforced the configured diff block rules.

Move the two reads into combineMatches so they run per push, matching the pattern already
used by checkMessages and checkAuthorEmails (which were unaffected by this bug).

Add a regression test that imports scanDiff, then loads a config containing a blocked
literal, and asserts the push is blocked. It fails against the old code and passes with
this fix.
@goldensyntax
goldensyntax requested a review from a team as a code owner November 13, 2026 15:37
@github-actions github-actions Bot added the fix label Nov 13, 2026
@goldensyntax goldensyntax self-assigned this Nov 13, 2026
@netlify

netlify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 3f9c0fd
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/6afe89c4e27094fa62f6d147

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.87%. Comparing base (6af363d) to head (3f9c0fd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1891   +/-   ##
=======================================
  Coverage   88.87%   88.87%           
=======================================
  Files         127      127           
  Lines        7092     7092           
  Branches     1318     1318           
=======================================
  Hits         6303     6303           
  Misses        493      493           
  Partials      296      296           

☔ 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.

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

Code changes LGTM, I would just remove all of the comments since clarification isn't needed 🙂

@goldensyntax

Copy link
Copy Markdown
Contributor Author

Thanks for the review @jescalada. I've removed the comments I added. The license headers and the existing comments in scanDiff.ts are untouched 🙂

@jescalada

Copy link
Copy Markdown
Contributor

@goldensyntax Thanks for fixing it up!

@jescalada
jescalada enabled auto-merge November 19, 2026 05:31
@jescalada
jescalada merged commit a599eb4 into main Nov 19, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scanDiff ignores commitConfig.diff.block rules from the --config file

2 participants