feat: add provenance fields (CM-1347)#4392
Conversation
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
PR SummaryLow Risk Overview
OpenAPI Reviewed by Cursor Bugbot for commit eb0c808. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Adds repository provenance to Akrites contact-detail responses.
Changes:
- Selects and maps declared/resolved repository URLs and mapping confidence.
- Documents the fields in OpenAPI.
- Adds mapper tests and centralizes nullable-number conversion.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
services/libs/data-access-layer/src/osspckgs/api.ts |
Projects provenance fields from package/repository joins. |
backend/src/api/public/v1/packages/mappers.ts |
Adds nullable-number conversion helper. |
backend/src/api/public/v1/packages/getPackage.ts |
Reuses the conversion helper. |
backend/src/api/public/v1/packages/akritesExternalPackageDetail.ts |
Reuses the conversion helper. |
backend/src/api/public/v1/packages/akritesExternalContactDetail.ts |
Adds provenance fields to contact responses. |
backend/src/api/public/v1/packages/akritesExternalContactDetail.test.ts |
Tests provenance mapping and null handling. |
backend/src/api/public/v1/akrites-external/openapi.yaml |
Documents the new required nullable fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| p.declared_repository_url AS "declaredRepositoryUrl", | ||
| r.url AS "resolvedRepositoryUrl", | ||
| pr.confidence AS "repoMappingConfidence", |
Summary
Adds repo provenance fields (
declaredRepositoryUrl,resolvedRepositoryUrl,repoMappingConfidence) to the root ofContactDetail, returned by/akrites-external/contacts/detailand:batch. Both endpoints already runBEST_REPO_LINK_JOINbut dropped these fields, so integrators had no way to tell which repo a package's security contacts belong to./packages/detailalready exposes the same semantics — this mirrors it so callers see identical field names across both endpoints.Changes
services/libs/data-access-layer/src/osspckgs/api.ts: extendedAkritesExternalContactDetailRowwithdeclaredRepositoryUrl(viaPick<PackageDbRow, ...>),resolvedRepositoryUrl, andrepoMappingConfidence; added the three columns togetContactDetailsByPurls's SELECT — they reuse ther/praliases already in scope fromBEST_REPO_LINK_JOIN, so no extra rows are scanned.backend/src/api/public/v1/packages/akritesExternalContactDetail.ts: added the three fields toAkritesExternalContactDetailand passed them through intoAkritesExternalContactDetail.backend/src/api/public/v1/packages/mappers.ts: extracted atoNullableNumberhelper (pg-promise returns numeric columns as strings;!= nullguard avoids coercingnullto0) and reused it inakritesExternalContactDetail.ts,akritesExternalPackageDetail.ts, andgetPackage.ts, which previously each inlined the same cast forrepoMappingConfidence.backend/src/api/public/v1/akrites-external/openapi.yaml: added the three fields toContactDetail(required, nullable), with descriptions mirroringPackageDetail's provenance wording. Kept them flat at the root (not nested under aprovenanceobject likePackageDetail) per the task spec —ContactDetail's schema is already flagged "shape not final," so nesting/labeling is left as a separate design decision.backend/src/api/public/v1/packages/akritesExternalContactDetail.test.ts: added the new fields to thebaseRow()fixture and added tests covering present-value passthrough, numeric-string coercion, and null-when-no-repo-link / null-when-no-declared-repository.Type of change
JIRA ticket
CM-1347