Commit Graph

78 Commits

Author SHA1 Message Date
Jamie Tanna 8b3a066756 test: remove redundant hostRules.clear() calls (#46584)
As we're now managing them via a `afterEach` in `test/setup.ts`, we can
remove any entries in tests themselves.

We don't update overrides of an outer hook or cases where there are more
explicit `clear()`s.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-09-30 11:22:18 +00:00
Sergei Zharinov ac2fc77641 refactor(http-mock): Remove request tracing (#44482)
* refactor(http-mock): remove request tracing

* test: replace remaining HTTP trace assertions
2026-09-23 09:01:01 +00:00
Gaël Jourdan-Weil 1d34441882 fix(http): improve warning message for ignored cross origin requests (#45802)
🐛 fix: improve warning message for ignored cross origin requests
2026-09-09 09:53:34 +00:00
Sebastian Poxhofer 05e1271376 test: use expect().resolves instead of awaiting inside expect (#45672)
Enables the vitest/prefer-expect-resolves oxlint rule and applies its
autofix across the spec suite.
2026-09-04 10:40:46 +00:00
Pham Manh Luc 2e89151d7e fix(github): treat graphql_rate_limit as rate limiting (#45396)
* fix(github): treat graphql_rate_limit as rate limiting

GitHub answers a spent app-installation budget with a GraphQL error carrying
code graphql_rate_limit, which neither call site recognised: the repository
query reported platform-unknown-error, and app authentication reported
Init: Authentication failure. Both readings send the user looking for a
problem that is not there, and neither is retried the way rate limiting is.

The two shapes are now recognised in one place and both call sites use it.

* fix(github): propagate GraphQL rate limits

* fix(github): preserve GraphQL response contract

---------

Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
2026-08-28 09:28:57 +00:00
Sebastian Poxhofer fbedd41e82 test: replace env operation with vi.stubEnv() (#45490)
* test: replace manual process.env mutation with vi.stubEnv

Enable Vitest's `unstubEnvs` so env stubs are reverted automatically
before every test, and convert the manual `process.env.X = ...` /
`delete process.env.X` pairs in specs to `vi.stubEnv()`.

This removes the hand-written `afterEach` cleanup blocks and the
`const OLD_ENV = process.env` / `process.env = { ...OLD_ENV }`
save-restore dance, which silently leaked state between tests when a
test set a variable without a matching delete.

Left as-is (incompatible with `unstubEnvs`, which unstubs before each
test, not after):
- module top-level env writes (cocoapods, gomod, post-update, pip-compile
  and bundler artifacts specs)
- `beforeAll` env writes -- the two in `util/http` moved to `beforeEach`

* test: stop asserting on ambient environment variables

Three specs asserted on values that the surrounding environment can
override, so they only passed on a machine that happened not to set them:

- `util/exec/env`: `getChildProcessEnv()` forwards every entry of
  `basicEnvVars`, but the spec only seeded a subset. Any other forwarded
  variable that was set ambiently (e.g. a lowercase `http_proxy`) leaked
  into the `toEqual` assertion. Clear all of them first.
- `util/git/index`: `process.env.GIT_SSH_COMMAND` deliberately overrides
  the default that the two env-inheritance tests assert on. Clear it.
- `logger/pretty-stdout`: the colorized level strings are built at import
  time, so the `beforeEach` setting `FORCE_COLOR` could never affect them
  -- it was dead code, and the test silently assumed a terminal without
  colour support. Derive the expectation the same way the module does.

* test(datasource/nuget): use a throwaway cache dir for nupkg downloads

The `determine source URL from nupkg` tests do not mock the filesystem,
so they really wrote downloaded packages into a fixed `/tmp/cache` path.
That fails wherever the system tmpdir is not writable, and two checkouts
running the suite at once would share the same directory.

Use `tmp.dir({ unsafeCleanup: true })` and clean it up afterwards, which
is the pattern the other specs that touch disk already use.

* feat(lint): add renovate/prefer-stub-env rule

Enforces in specs what the migration to `vi.stubEnv` established:

- assigning to or deleting `process.env.X` inside `beforeEach`, `afterEach`,
  `it` or `test` is reported, with a fixer that rewrites it to `vi.stubEnv()`
- module scope, `describe` bodies and `beforeAll` / `afterAll` are left alone:
  `unstubEnvs` reverts stubs *before* each test, so a stub created there is
  gone by the time the first test runs, and those must keep assigning directly
- replacing the `process.env` object is reported everywhere and never fixed.
  `vi.stubEnv()` captures the original object when the worker starts, so after
  a reassignment its deletes silently target the old object

The rule found 28 further violations in specs the earlier sweep missed, since
that one was anchored on `delete process.env`. Twelve were auto-fixed; the
rest replaced `process.env` wholesale and are now `clearEnv()` from test/util.

`util/exec/index.spec.ts` opts out with a comment: it asserts on the whole
child env, and `vi.stubEnv()` cannot express that because it maps `PROD`,
`DEV` and `SSR` onto '' instead of deleting them.
2026-08-28 09:26:20 +00:00
goda6565 9cc1ab0df6 fix(http/github): support cursor pagination (#45241)
* fix(http/github): support cursor pagination

* fix(http/github): harden cursor pagination

* fix(http/github): log pagination mode
2026-08-24 14:24:25 +00:00
Sebastian Poxhofer 16ef1715e9 refactor(linters): add rules for @sindresorhus/is helpers (#45229)
* feat(lint): add renovate/prefer-is-helpers and renovate/prefer-is-object rules

Flag ad-hoc type checks that have @sindresorhus/is equivalents:
- .filter(Boolean) -> .filter(isTruthy)
- typeof x === 'string' -> isString(x)
- x === null || x === undefined -> isNullOrUndefined(x) (and negation)

The typeof x === 'object' shape lives in a separate suggestion-only rule
(renovate/prefer-is-object, kept at warn) because isObject()/isPlainObject()
are not drop-in equivalents: null, arrays and functions behave differently.

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

* refactor: fix renovate/prefer-is-helpers violations

Replace ad-hoc type checks with @sindresorhus/is helpers across lib/:
- 13x .filter(Boolean) -> .filter(isTruthy)
- 36x typeof x ==/!== 'string' -> isString(x) / !isString(x)
- 6x x === null || x === undefined -> isNullOrUndefined(x) (and negation)

Promote renovate/prefer-is-helpers to error now that the codebase is clean.
renovate/prefer-is-object stays at warn: its 15 remaining sites guard
parsed YAML/JSON or unknown values where isObject()/isPlainObject() are
not provably equivalent (null/array/function semantics).

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

* refactor: enforce renovate/prefer-is-object at error level

Resolve the 15 remaining warnings and raise the rule from warn to error:

- Migrate 10 sites to isObject() where the guarded value provably cannot
  be a function (parsed YAML/JSON, typed exec command arguments, or
  test-controlled fixtures): helm-values, woodpecker, bun, pre-commit
  managers, exec utils, file package cache, and the github http spec.
  In the bun manager this also fixes a latent crash where a null
  `workspaces` value would throw on the `in` operator.
- Keep 5 sites as reasoned oxlint-disable comments where excluding
  functions is load-bearing: the byte-exact fingerprint canonicalizer
  (2), the circularity walker, the zod result guard, and the generic
  hasKey helper.

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 14:22:03 +00:00
Jamie Tanna edb2217952 fix(platform/github): don't follow Link headers with different hosts
To prevent potential SSRF attempts, we can ignore a
misconfigured/malicious `next` link, and log a warning.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
2026-08-04 09:09:26 +01:00
Sebastian Poxhofer c41b46bac3 feat(logging): do not use dynamic fields in log messages with severity WARN or higher (#44560)
* ci(linter): add renovate/logger-static-message rule

Adds a custom oxlint rule that enforces a static msg component for
logger.warn/error/fatal calls (including logger.once variants) so the
messages can be grouped in metrics and error catching services, per
docs/development/best-practices.md. It also flags metadata properties
named 'error' that hold error-ish values, because the bunyan serializer
only handles the 'err' key.

The rule is enabled as an error for lib/ production code and disabled
for spec files. All 33 pre-existing violations are fixed by moving
interpolated values into the metadata object, making messages static,
and renaming 'error' metadata keys to 'err'. Affected log-message
assertions in co-located specs are updated accordingly.

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

* ci: ignore validator output

* fixup new merged in log messages

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 06:53:37 +00:00
Sebastian Poxhofer b106668a95 refactor(oxlint): enable typescript/no-useless-default-assignment (#44419)
- Convert `param: T | undefined = undefined` to optional `param?: T`.
- Drop dead `= false` defaults on the required cache-provider options.
- Make `GraphqlPaginatedContent.nodes/edges` optional so the `= []`
  fallbacks (load-bearing for partial GraphQL connections) are valid.
- Type the unchecked `default_branch` response field as optional so
  the `'HEAD'` fallback is retained.
- Drop `tag = undefined` from the Forgejo/Gitea/GitLab preset configs.

Part of #43845

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 16:38:48 +00:00
Sebastian Poxhofer a5393774a2 fix(http/github): handle Github got errors containing falsely an object (#44259)
* fix(http/github): handle Github got errors containing falsely an object

* test: improve test naming
2026-06-26 16:38:44 +00:00
Jamie Tanna 89be048657 refactor: use GlobalConfig for productLinks (#44098)
As a follow-up to e1e5c398e0, we can make
sure that we remove references to hardcoded docs site URLs, by wiring in
the `GlobalConfig.get(...)` call.

To do this, we need to make sure that `productLinks` exists to be called
by `GlobalConfig.get`.

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
2026-06-19 10:34:03 +00:00
renovate[bot] 9245b57c58 chore(deps): update linters to v1.67.0 (main) (#42416)
* chore(deps): update linters to v1.67.0

| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | oxlint  | 1.57.0 | 1.67.0 |

* test(oxlint): deactivate new tests for now

* fixup linting errors

* revert googleAuth mock implementation

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
2026-06-06 14:09:05 +00:00
Sebastian Poxhofer 0793274b86 refactor: prefer templates rather than + in test files (#43441)
refactor: prefer templates rather than `+`
2026-05-19 09:52:28 +00:00
Sergei Zharinov 0ae44810fc fix(http): detect x-access-token prefix before hostType-based auth branching (#42083)
* fix: Add `github-digest` to `GITHUB_API_USING_HOST_TYPES` list

* fix(http): detect x-access-token prefix before hostType-based auth branching

Moves GitHub App installation token detection (`x-access-token:` prefix)
before the hostType-based authorization chain in `applyAuthorization`.
This ensures correct `token` scheme auth for any GitHub-related hostType,
not only those listed in `GITHUB_API_USING_HOST_TYPES`.

* test(http/auth): add regression test for GitHub App token with non-listed hostType

* Fixes

* Fix tests
2026-03-24 17:11:56 +00:00
renovate[bot] e752a3db29 build(deps): update dependency got to v14 (main) (#41302)
* build(deps): update dependency got to v14

| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | got     | 12.6.1 | 14.6.6 |

* test: fix tests

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2026-02-19 17:50:48 +00:00
Sergei Zharinov 9d857c1f68 refactor(lint): Organize imports with biome (#40966) 2026-02-06 13:40:01 +00:00
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00
Jamie Tanna bd6b7c3d9a fix(github): warn on rate limit errors (#39585)
As noted in #39406, we're seeing a number of self-hosted users who have
missed the onboarding requirement for a `GITHUB_COM_TOKEN` for their
authentication to `github.com`.

On top of the docs improvements in #39406, we can make this clearer by
adding a warning log when we're going to report a `rate-limit-exceeded`
error, noting which hostname is failing (in case of GitHub Enterprise).

This requires a slightly duplicated `fail` function re-definition, so we
can override the baseUrl.

In the case that the request fails for `github.com`, we can also point
to our docs for the configuration needed.
2025-11-27 17:53:00 +00:00
Rhys Arkins a0895e6c28 feat: log one warning for 401 github (#36235) 2025-06-01 09:13:56 +00:00
Michael Kriese 19c115c813 test: cleanup (#34785) 2025-03-13 17:52:09 +00:00
Michael Kriese 593a92655e feat: refactor http (#34550) 2025-02-28 14:40:04 +00:00
renovate[bot] 0299455412 chore(deps): update dependency nock to v14 (main) (#34557)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-02-28 14:20:08 +00:00
Michael Kriese 997c23502e test: migrate to vitest (#34475)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2025-02-26 09:35:54 +00:00
renovate[bot] 55845508b6 chore(deps): update eslint monorepo to v9 (major) (#33573)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-02-20 11:31:13 +00:00
Sergei Zharinov 9b4e515024 refactor(http): Separate getJson and getJsonUnchecked (#33651) 2025-01-17 14:18:00 +00:00
Sebastian Poxhofer 1f3ab66d33 chore(http/github): add utility function to fetch raw files (#30155)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-08-21 12:56:27 +00:00
Nils Andresen 16589bfb69 feat(github): Add the possibility to link a Milestone (#27343)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-02-21 20:47:48 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Michael Kriese 84a97a62fa test(perf): improve test speed (#24323) 2023-09-08 11:40:04 +00:00
Jamie Magee a6dfa70c1d chore: migrate to structuredClone (#20885)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2023-04-27 05:06:22 +00:00
Daniel Silva 0e47a1072c feat(platform/github): Support rewrite pagination links with the server's base URL (#19888)
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-02-16 15:25:56 +00:00
Sebastian Poxhofer 871cea19b7 feat(http): set by default Accept header for json requests (#19202)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-12-01 18:48:45 +01:00
Sergei Zharinov 3c56aeca17 refactor(tests): Use codeBlock tagged literal (#18916) 2022-11-15 08:35:36 +00:00
Michael Kriese 6dd4ea3c74 feat(github): use repo url to get token (#17179) 2022-08-29 07:37:45 +00:00
Michael Kriese 0316a5e62d test: use jest v29 (#17151) 2022-08-16 14:22:29 +02:00
RahulGautamSingh 3d31fa371d refactor(lib/util): strict null check for test files (#15812)
* add types for tmp

* expand files in lib/util

* update yarn lock

* Update tsconfig.strict.json

* util/exec

* util/git

* util/http

* Revert "util/exec"

This reverts commit 96cf479a1b.

* update strict.json

* redo util/exec

* revert util/git

* util/merge-confidence

* update util/git

* util/package-rules

* fix util/git

* util/template

* util/

* revert extras

* rm newline

* add tmp back

* apply suggestion from review

* util/cache

* more changes

* Update tsconfig.strict.json

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-06-19 21:17:46 +00:00
Sergei Zharinov a06e5d9ce7 refactor(cache): Separate data and metadata for repo cache (#15117) 2022-04-16 06:51:29 +01:00
Sergei Zharinov d663859207 feat(github): Fetch PRs using cacheable REST (#14907) 2022-04-15 17:21:09 +00:00
Michael Kriese 64f5bd5f03 test: enforce lint style rules (#15085) 2022-04-12 14:49:49 +00:00
Michael Kriese 443bef5c52 test: cleanup snapshot tests (#15082) 2022-04-12 15:09:19 +01:00
Rhys Arkins dca3418bbd refactor: lib/modules (#14488)
Moves datasource, manager, platform and versioning code from lib/ into new lib/modules/

BREAKING CHANGE: External tools must update paths to datasource, manager, platform and versioning
2022-03-04 09:04:02 +01:00
Rhys Arkins 6c9aad38a8 refactor: remove unnecessarily long paths in imports and mocks (#14429) 2022-02-26 16:09:01 +00:00
Sergei Zharinov 8a7abfdf01 refactor(github): Convert datasources to class form (#14124)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2022-02-13 03:24:40 +00:00
Sergei Zharinov 3b14ef2869 feat(github): Remember GraphQL optimal page size (#13047)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2022-01-18 15:36:44 +00:00
Sergei Zharinov 9a2e37f5bd fix(http/github): Preserve search params for paginated requests (#13506)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-01-12 11:31:36 +00:00
Sergei Zharinov 030b1a61a4 refactor(util/http): Strict null checks for http utils (#13416)
* refactor(util/http): Strict null checks for http utils

* More tests for queue.ts

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-01-09 21:22:27 +00:00
Oleg Krivtsov 9b2c4b5af2 test: error 502 is handled correctly in GitHub graphql (#13167)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2021-12-21 08:16:41 +00:00
Rhys Arkins cfc4c48a47 fix(github): handle secondary rate limit (#12741) 2021-11-18 16:47:17 +01:00