Commit Graph

13 Commits

Author SHA1 Message Date
Matthew Nitschke ac22678812 feat(datasource/npm): integrity and tarball extraction (#44315)
* added support for extracting integrity and tarball from npm datasource

* test(datasource/npm): keep integrity and tarball in packument shape assertions

The packument-trimming tests on main pinned a cached shape that dropped
`dist.tarball`, so they broke once the schema started retaining
`integrity` and `tarball`. Update both expectations to the new shape and
cover `integrity` alongside `tarball`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(workers/lookup): expect integrity and tarball on npm updates

`generateUpdate` copies `downloadUrl` and `newDigest` from the release
onto the update, so every npm lookup in these tests now carries the
tarball URL and, where the packument fixture has one, the integrity
hash. Pin and rollback updates are built without those release fields,
so their expectations are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Michael Kriese <michael.kriese@mend.io>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 10:09:59 +00:00
Jamie Tanna a61de24310 fix(datasource/npm): don't break on non-string homepage (#45358)
As reported in #45357, changes in
116c3d610c caused a regression for cases
where an npm package had `homepage: [...]`.

We should restore the `catch(undefined)` and add a test to make sure
this isn't broken in the future.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-19 20:41:56 +00:00
Jamie Tanna 116c3d610c fix(datasource/npm): handle absent homepages (#45219)
* fix(datasource/npm): handle absent `homepage`s

As a follow-up to 89f526e0b1, this handles
it at the response from the npm registry.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fixup! fix(datasource/npm): handle absent `homepage`s

* fixup! fix(datasource/npm): handle absent `homepage`s

---------

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-17 09:34:29 +00:00
Jamie Tanna 89f526e0b1 fix(datasource/npm): handle absent homepages (#44999)
* fix(datasource/npm): handle absent `homepage`s

As noted in #44991, for some private packages.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fixup! fix(datasource/npm): handle absent `homepage`s

* fixup! fix(datasource/npm): handle absent `homepage`s

---------

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-03 16:24:15 +00:00
Jamie Tanna 49fa2289b6 fix(datasource/npm): handle old-style dependencies/devDependencies (#44998)
As found when we read i.e. `deep-diff`, via #44991.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-03 10:05:00 +00:00
Sebastian Poxhofer a31f9cf0f9 refactor(schemas): prefer Nullish schema utils instead of z.nullish() (#44565)
* ci(linter): add renovate/prefer-zod-nullish rule

Add a custom oxlint rule that flags zod chains calling .optional() and
.nullable() adjacently (in either order) and suggests .nullish(), which
is equivalent (both accept undefined | null in zod v4).

Fix all 26 pre-existing violations across 6 schema files.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* ci(linter): prefer schema-utils Nullish over zod .nullish()

Rename prefer-zod-nullish to prefer-nullish-util and extend it to flag
.nullish() itself, including the standalone forms z.nullish(x) and
z.optional(z.nullable(x)). Migrate all call sites to Nullish() and
DeepNullish() from schema-utils, which normalize null to undefined in
parsed output. Schemas with more than one nullish position are wrapped
in DeepNullish(); nullish object properties with nullish members use
Nullish(DeepNullish(...)) to keep the optional property type marker.

Spec files are exempt (result.spec.ts intentionally tests
null-preserving parses). Spec assertions expecting null in parsed
output were updated to undefined. Note: docker manifests with an
explicit "mediaType": null are now accepted and treated like an absent
mediaType instead of failing the discriminated union.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 10:15:55 +00:00
Jamie Tanna 1754bb86ad fix(datasource/npm): handle array of repository for legacy packages (#44061)
When attempting to perform dependency updates on the `tmp` package,
parsing a previous version's Zod schema results in a lookup failure, as
it had an incorrect form of `repository` as of tmp@0.0.4.

We can handle this by treating it more loosely to convert an array of
repositories into a single element, and handle this on both a
per-version and per-package lookup.

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
2026-06-18 08:39:57 +00:00
Mike Ryan 8bbce59ece fix(datasource/npm): tolerate non-string time entries in packument (#43779)
* fix(datasource/npm): tolerate non-string `time` entries in packument

JFrog Artifactory npm registries emit `"unpublished": null` under the
packument `time` field. Since the schema declared `time` values as
`z.string()`, the `null` failed validation and Zod rejected the entire
packument, so every package lookup returned no-result.

Strip non-string `time` entries via a shared `PackumentTime` transform so
a stray metadata key cannot invalidate the whole packument, while keeping
the real version->timestamp entries the datasource relies on.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(datasource/npm): use LooseRecord for packument time

Per PR review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 14:04:51 +00:00
Sebastian Poxhofer c908d078ef fix(datasource): replace getJsonUnchecked in npm/Node/PyPI/Go (#43699)
* fix(datasource): replace getJsonUnchecked with validated getJson in npm/Node/PyPI/Go

Replace all getJsonUnchecked calls in npm, Node.js, PyPI, and Go datasources
with Zod-validated getJson calls:

- datasource/npm: add NpmResponseSchema to schema.ts (shared with presets)
- config/presets/npm: migrate to NpmResponseSchema with passthrough version fields
- datasource/node-version: add NodeReleasesSchema using LooseArray
- datasource/pypi: add PypiJSONSchema (nullable+catch for lenient empty-body handling)
- datasource/go: add VersionInfoSchema for both versionInfo and getLatestVersion calls

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* some manual cleaning up

* removing schema level catch

* removing some more types

* refactor: rename schema

* fix linter errors

* remove schema suffix which hasn't been catched by linter

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03 19:14:50 +00:00
Sebastian Poxhofer 15f4bd8eff chore: migrate from zod/v3 to zod/v4 (#43691)
* chore: migrate from zod/v3 to zod/v4

This commit contains the logic changes

* chore: migrate imports from zod/v3 to zod/v4

This contains import updates and adds explicit record keys as zod/v4 requires these now

* ci: enforce usage of zod/v4
2026-05-30 16:01:58 +00:00
Jamie Tanna e0ede0677c fix(datasource/npm): catch invalid homepage (#42892)
In a similar fix to 06cf949974, this fixes
early versions of `https://registry.npmjs.org/fs-extra` returning an
array value for `homepage`, resulting in no caching for these responses.
2026-04-24 16:41:14 +00:00
Michael Kriese 06cf949974 fix(datasource/npm): catch invalid engines (#42718) 2026-04-17 17:38:49 +00:00
Sergei Zharinov b359a1de4d feat(npm): Trim response data before caching (#42559)
* feat(cache): Add `writeSchema` transform to package cache

* feat(npm): Trim response data before caching
2026-04-12 17:22:32 +00:00