Skip to content

fix(scoring): skip base_ref gate when mirror omits base_ref - #1676

Open
Mahdi3Bani wants to merge 1 commit into
entrius:testfrom
Mahdi3Bani:fix/mirror-scoring-null-base-ref
Open

fix(scoring): skip base_ref gate when mirror omits base_ref#1676
Mahdi3Bani wants to merge 1 commit into
entrius:testfrom
Mahdi3Bani:fix/mirror-scoring-null-base-ref

Conversation

@Mahdi3Bani

Copy link
Copy Markdown

Summary

check_merged_branch_eligibility gated the base-ref check on base_ref or ''. When the mirror omits base_ref, that becomes '', which never matches the acceptable branch set — so the PR is rejected at load time by _should_skip_merged_mirror_pr, never enters merged_prs, and earns no OSS contribution score.

Pre-backfill mirror rows legitimately carry no branch metadata. MirrorPullRequest declares base_ref: Optional[str] and populates it with data.get('base_ref'), so None is an expected runtime value, not a corrupt row.

Two places in the codebase already treat missing branch metadata as fall-through rather than grounds for rejection:

  • Issue discoveryissue_discovery/scan.py gates on sp.base_ref is not None, with a comment stating that a missing base_ref means pre-backfill data and should fall through. Covered by test_missing_base_ref_falls_through_to_solved.
  • This same function — the head_ref check falls through on missing head_ref / head_repo_full_name, and the docstring documents that as intended behavior.

The base_ref gate was the odd one out. This changes it to gate on presence, restoring parity across the two paths. An explicitly malformed (empty-string) base_ref is still rejected — only genuinely absent metadata falls through.

Also widens base_ref on the _pr test helper from str to str | None. It had drifted from the model, which is why the null case had no coverage — the helper couldn't express it. head_ref was already str | None there.

Related Issues

Fixes #1636

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • Tests added/updated
  • Manually tested

Added test_null_base_ref_skips_check, mirroring the existing test_null_head_ref_skips_check. Confirmed it fails on test without the source change and passes with it.

Full suite: 893 passed. pre-commit run --all-files and --hook-stage pre-push (ruff, pyright, vulture, pytest) all pass.

No CLI output changes.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

`check_merged_branch_eligibility` gated on `base_ref or ''`, so a NULL
`base_ref` became `''`, never matched the acceptable branch set, and the
merged PR was dropped at load time — it never entered `merged_prs` and
earned no OSS contribution score.

Pre-backfill mirror rows legitimately have no branch metadata. Issue
discovery already treats this as fall-through (`scan.py`, gated on
`sp.base_ref is not None`, covered by
`test_missing_base_ref_falls_through_to_solved`), and this same function
already falls through on missing `head_ref`/`head_repo_full_name` per its
own docstring. The base_ref gate was the odd one out.

Gate on presence instead, restoring parity across the two paths. An
explicitly malformed (empty-string) base_ref is still rejected.

Fixes entrius#1636
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Aug 3, 2026
@Mahdi3Bani

Copy link
Copy Markdown
Author

#1641 predates this and makes the same change to the base_ref gate — I missed it before opening this one, apologies for the duplicate.

The difference is test coverage: this adds test_null_base_ref_skips_check, and widens base_ref on the _pr test helper from str to str | None. The helper had drifted from MirrorPullRequest.base_ref: Optional[str], which is why the null case had no coverage — pyright rejects the test without that change.

Happy to close this in favour of #1641 if you'd rather take that one. Whichever lands, I'd suggest the regression test comes with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(validator): OSS mirror scoring still rejects merged PRs with null base_ref on test

1 participant