Skip to content

Add version endpoints to the Collection API#1261

Merged
Ndpnt merged 17 commits into
mainfrom
update-collection-api-clean
Jul 7, 2026
Merged

Add version endpoints to the Collection API#1261
Ndpnt merged 17 commits into
mainfrom
update-collection-api-clean

Conversation

@Ndpnt

@Ndpnt Ndpnt commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Adds read endpoints to the Collection API for browsing recorded versions:

  • List (paginated): GET /versions, GET /versions/{serviceId}, GET /versions/{serviceId}/{termsType}
  • Retrieve: GET /version/{versionId} and GET /version/{serviceId}/{termsType}/latest, and enriches the existing by-date endpoint

Version responses now expose serviceId, termsType, isFirstRecord, isTechnicalUpgrade, source fetchUrls, navigation links and diff statistics, implemented symmetrically for the Git and MongoDB backends.

  • Breaking: the GET /service/{serviceId} not-found response is now JSON instead of plain text
  • Hardens version lookups against Git argument injection (unauthenticated arbitrary file write) and repository-path disclosure, and returns generic messages for unexpected 500s

@Ndpnt Ndpnt requested a review from clementbiron July 6, 2026 15:42
@Ndpnt Ndpnt force-pushed the update-collection-api-clean branch 3 times, most recently from 6431642 to d865fb6 Compare July 7, 2026 08:48

@clementbiron clementbiron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚀

@Ndpnt Ndpnt force-pushed the update-collection-api-clean branch from ed2684b to 67c2e58 Compare July 7, 2026 09:02
Ndpnt added 10 commits July 7, 2026 11:11
The single-version endpoints pass the URL `versionId` straight to `findById`, which placed it in a `git log` revision position with no separator. A value such as `--output=/path` was therefore parsed by git as an option, letting an unauthenticated caller create or overwrite an arbitrary file with `git log` output.

Reject any record ID that is not a hexadecimal commit SHA before it reaches git, mirroring the `ObjectId.isValid` guard already used by the MongoDB backend, and pass validated IDs after `--end-of-options` as a second line of defence.
The version lookups compose a service ID, terms type or document ID into a Git pathspec. A value with a path separator or a `..` segment resolved outside the repository, and the resulting fatal git error exposed the repository filesystem location.

Reject such values before they reach git, where they cannot match a record anyway, so the lookups return empty and the endpoints answer 404 instead of 500.
Diff statistics are only meaningful for the Git backend, which retains diffs; the MongoDB backend stores full snapshots and cannot provide them. The interface declared the method as returning numbers while MongoDB stubbed it with nulls.

Move the null default into the repository interface so snapshot-based backends inherit it, drop the MongoDB stub, and document the statistics as an optional, nullable capability.
@Ndpnt Ndpnt force-pushed the update-collection-api-clean branch from 67c2e58 to 15e5898 Compare July 7, 2026 09:11
@Ndpnt Ndpnt merged commit 08c12c5 into main Jul 7, 2026
8 checks passed
@Ndpnt Ndpnt deleted the update-collection-api-clean branch July 7, 2026 09:33
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