fix(scoring): skip base_ref gate when mirror omits base_ref - #1676
Open
Mahdi3Bani wants to merge 1 commit into
Open
fix(scoring): skip base_ref gate when mirror omits base_ref#1676Mahdi3Bani wants to merge 1 commit into
Mahdi3Bani wants to merge 1 commit into
Conversation
`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
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 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
check_merged_branch_eligibilitygated the base-ref check onbase_ref or ''. When the mirror omitsbase_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 entersmerged_prs, and earns no OSS contribution score.Pre-backfill mirror rows legitimately carry no branch metadata.
MirrorPullRequestdeclaresbase_ref: Optional[str]and populates it withdata.get('base_ref'), soNoneis 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_discovery/scan.pygates onsp.base_ref is not None, with a comment stating that a missingbase_refmeans pre-backfill data and should fall through. Covered bytest_missing_base_ref_falls_through_to_solved.head_refcheck falls through on missinghead_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_refis still rejected — only genuinely absent metadata falls through.Also widens
base_refon the_prtest helper fromstrtostr | None. It had drifted from the model, which is why the null case had no coverage — the helper couldn't express it.head_refwas alreadystr | Nonethere.Related Issues
Fixes #1636
Type of Change
Testing
Added
test_null_base_ref_skips_check, mirroring the existingtest_null_head_ref_skips_check. Confirmed it fails ontestwithout the source change and passes with it.Full suite: 893 passed.
pre-commit run --all-filesand--hook-stage pre-push(ruff, pyright, vulture, pytest) all pass.No CLI output changes.
Checklist