Skip to content

feat: add filters and risk sort to GET /v1/packages#4203

Merged
gaspergrom merged 3 commits into
mainfrom
feat/packages-name-search
Jun 11, 2026
Merged

feat: add filters and risk sort to GET /v1/packages#4203
gaspergrom merged 3 commits into
mainfrom
feat/packages-name-search

Conversation

@gaspergrom

@gaspergrom gaspergrom commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends GET /v1/packages with the additional filters and sort options currently handled post-fetch on the consumer side, moving them into the DB layer.

  • Status filter (status=unassigned|open|assessing|active|...) — filters by stewardship status; unassigned includes packages with no stewardship row
  • Health band filter (healthBand=healthy|fair|concerning|critical) — filters by scorecard score (0–10 × 10 = 0–100 health), using best-confidence linked repo
  • Vuln severity filter (vulnSeverity=any|high|critical) — filters by worst advisory severity rank across all open advisories
  • Risk sort (sortBy=risk) — composite score: impact + health deficit + vuln exposure + bus factor + staleness
  • Health in responsehealth field now returns the scorecard-based 0–100 value instead of always null
  • Lifecycle null exclusion bug — when lifecycle is passed, packages with no registry status (p.status IS NULL) are excluded from results
  • Name search (already on branch) — name param for case-insensitive ILIKE filter

Changes

  • backend/src/api/public/v1/packages/listPackages.ts — new Zod params (status, healthBand, vulnSeverity, risk sort), forwarded to DAL; filters and health in response updated
  • services/libs/data-access-layer/src/osspckgs/api.ts — new ListPackagesOptions fields; added LATERAL joins for scorecard (r_sc) and max advisory severity rank (ap_severity); shared laterals fragment used in both paginated query and empty-page COUNT fallback; risk sort expression inline in SQL

@gaspergrom gaspergrom self-assigned this Jun 11, 2026
Copilot AI review requested due to automatic review settings June 11, 2026 20:50

Copilot AI 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.

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
…ackages list endpoint

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
@gaspergrom gaspergrom force-pushed the feat/packages-name-search branch from 4a7e060 to 4e0679d Compare June 11, 2026 21:21

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4e0679d. Configure here.

// from leaking into filtered results.
if (opts.lifecycle) {
conditions.push('p.status IS NOT NULL')
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lifecycle filter ignores value

Medium Severity

When lifecycle is passed from the list endpoint, the DAL only adds p.status IS NOT NULL and never compares the requested lifecycle value (active, stable, declining, abandoned). Every lifecycle choice returns the same result set while the response still echoes the chosen filter.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4e0679d. Configure here.

JOIN repos r ON r.id = pr.repo_id
WHERE pr.package_id = p.id
ORDER BY pr.confidence DESC
LIMIT 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Scorecard repo pick inconsistent

Medium Severity

The new r_sc lateral picks a linked repo with ORDER BY pr.confidence DESC only. Package detail elsewhere breaks ties by preferring declared source, so list health, healthBand, and sortBy=health|risk can use a different scorecard than the detail view for the same package.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4e0679d. Configure here.

@gaspergrom gaspergrom changed the title feat: add name search filter to packages list endpoint feat: add filters and risk sort to GET /v1/packages Jun 11, 2026
@gaspergrom gaspergrom merged commit e5b2d7b into main Jun 11, 2026
18 checks passed
@gaspergrom gaspergrom deleted the feat/packages-name-search branch June 11, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants