Skip to content

fix(registry): apply transformInfo to ~preview JSON - #1607

Merged
ricardo-devis-agullo merged 1 commit into
masterfrom
fix/preview-transform-info
Nov 19, 2026
Merged

ricardo-devis-agullo merged 1 commit into
masterfrom
fix/preview-transform-info

Conversation

@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1606. GET /:name[/:version]/~preview with a JSON Accept header returned the raw package.json, bypassing discovery.transformInfo and ignoring discovery.api, so fields hidden from ~info (e.g. owners, author) were still reachable there.

  • Run discovery.transformInfo on the ~preview JSON response, the same way as ~info: requestVersion is added after the transform, and throwing/rejecting/non-object returns respond with a 500 (TRANSFORM_INFO_FAILED), never the raw package.json.
  • Only serve the ~preview JSON when discovery.api is enabled; otherwise respond 401 with DISCOVERY_API_DISABLED. Behaviour change for registries with api: false, which previously still exposed it.
  • The HTML preview is unchanged (it only uses name, version and oc.files.imports), but it no longer throws when the info has no oc, which can happen when the preview comes from a fallback registry whose transform strips it.

Test plan

  • Unit tests for ~preview JSON: transformed output with requestVersion, 500 on transform failure, 401 when discovery.api is disabled
  • Unit test rendering the HTML preview from info without oc
  • npm run build (lint + tsc) and full oc test suite (1209 passing)

Generated with Devin

The ~preview route returned the raw package.json when JSON was
requested, so anything hidden by discovery.transformInfo on ~info was
still reachable there, even with discovery.api disabled.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@ricardo-devis-agullo
ricardo-devis-agullo merged commit 6b3eccb into master Nov 19, 2026
3 checks passed
@ricardo-devis-agullo
ricardo-devis-agullo deleted the fix/preview-transform-info branch November 19, 2026 12:04
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.

1 participant