Skip to content

[bug] miners API: getPullRequestsByRepo joins pr_review_summary and repos with exact-case while windowing on LOWER(repo_full_name), causing join misses for mixed-case repos #152

@Tet-9

Description

@Tet-9

Duplicate check

Item Relation
#140 (open) Webhook gate case-sensitive lookup — different code path
#120 (open) Uninstall case-sensitive PK — different code path
#70 (closed) Admin validateRepoFullName lowercase — different code path
No open/closed issue getPullRequestsByRepo mixed casing within same query

Description

getPullRequestsByRepo in miners.service.ts joins the windows CTE on LOWER(p.repo_full_name) for the main filter, but then joins pr_review_summary and repos using exact-case p.repo_full_name:

The window join uses LOWER() but the LEFT JOINs to pr_review_summary and repos use exact-case. If rows in those tables were stored under a different casing variant than pull_requests.repo_full_name, both LEFT JOINs return NULL — silently dropping review summary and repo metadata from scoring output for that miner.

Steps to Reproduce

  1. Ingest a repo stored as Org/Repo in repos and pr_review_summary.
  2. Ingest pull requests stored as org/repo (lowercase) in pull_requests.
  3. Call POST /api/v1/miners/{authorId}/pulls with since_by_repo targeting org/repo.
  4. Observe rs.* and r.* columns are NULL in results despite data existing.

Expected Behavior

All join conditions should use the same casing normalization so review summary and repo metadata are never silently dropped. Suggested fix:

LEFT JOIN pr_review_summary rs ON LOWER(rs.repo_full_name) = LOWER(p.repo_full_name)
LEFT JOIN repos r ON LOWER(r.repo_full_name) = LOWER(p.repo_full_name)

Files

packages/das/src/api/miners/miners.service.tsgetPullRequestsByRepo query (~lines 229-240).

Environment

  • Runtime/Node version: Node 20
  • OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions