Commit Graph

107 Commits

Author SHA1 Message Date
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
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 c32e2391a0 refactor(linters): add prefer-coerce-object rule (#45493)
Refs #45216

The object counterpart to `prefer-coerce-array`: `x ?? {}` becomes
`coerceObject(x)`. The rule flags a `??` whose default is a bare `{}`
literal, so a populated default or an asserted `({} as Foo)` still
passes; a `x ?? y ?? {}` chain maps onto `coerceObject(x, y)`.

Every hit across `lib/` converted cleanly, so no disable comments were
needed.
2026-08-28 09:27:59 +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 58771bb183 refactor(linters): enabled oxlints func-style (#44691)
* refactor(oxlint): enable func-style

Enable the built-in func-style rule as ["warn", "declaration"] so that
named functions are written as function declarations instead of arrow or
function expressions assigned to variables, matching the convention in
docs/development/best-practices.md (Functions section). Inline arrow
callbacks are unaffected; prefer-arrow-callback continues to cover the
callback direction.

Severity is "warn" instead of "error" as a fallback: a repo-wide run
found 196 pre-existing violations (70 in spec files, 126 in production
code), exceeding the 80-violation fix threshold for this change, so no
violations were fixed here. Follow-up work can convert the offenders
(largest clusters: lib/modules/versioning/ruby, lib/util/cache/package,
lib/modules/versioning/maven, lib/modules/versioning/gradle) and then
raise the rule to "error". Note oxlint 1.72 also supports an
allowTypeAnnotation option if typed consts should remain arrows.

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

* ci(linter): enforce func-style at error

* refactor(func-style): convert const-arrow functions to declarations in with-cache spec and ruby versioning

* refactor(func-style): convert const-arrow functions to declarations in maven/gradle modules

* refactor(func-style): convert const-arrow functions to declarations in remaining versioning modules

* refactor(func-style): convert const-arrow functions to declarations in platform modules

Discriminated-union closures (ensureCommentRemoval byTopic/byContent
helpers in github, gitlab, bitbucket, bitbucket-server) needed the
narrowed field passed explicitly as a parameter, since function
declarations are hoisted and lose the outer if-narrowing that inline
arrow-function closures previously relied on.

* refactor(func-style): convert const-arrow functions to declarations across util/manager/datasource modules

One case (logger/renovate-logger.ts logOnceFn) is kept as an arrow
function with a documented oxlint-disable: it is stored on
this.logger.once[level] and relies on lexically-bound this, which a
hoisted function declaration would not preserve.

* refactor(func-style): convert remaining const-arrow test helpers to declarations

get-updated.spec.ts: hoisted expectPipCompilePackageAndLockFile to
module scope (it only closes over the module-level pipCompile mock)
and added a documented oxlint-disable for vitest/expect-expect on its
caller test, since oxlint's expect-expect check does not trace
assertions through an externally-defined helper function.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 11:14:22 +00: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 9717259ffc refactor(oxlint): enable no-else-return and unicorn/no-lonely-if (#44553)
Enable no-else-return (with allowElseIf: false) and unicorn/no-lonely-if
as errors in .oxlintrc.json and fix all 131 pre-existing violations
(91 no-else-return, 40 unicorn/no-lonely-if) across 98 files.

The no-else-return violations were fixed with the oxlint autofix
(iterated to a fixpoint, plus two else-if chains that required
--fix-dangerously) followed by Prettier formatting. One comment dropped
by the autofix in lib/modules/manager/pub/artifacts.ts was restored
manually. The unicorn/no-lonely-if violations were merged by hand,
preserving comments and coverage-ignore hints.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 12:11:21 +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 63527b66d0 refactor(utils/http/github): use zod schema for GitHub errors (#44267) 2026-07-01 14:38:10 +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
Jamie Tanna e1e5c398e0 chore: ensure we use productLinks for docs site links where possible (#44066)
* chore: ensure we use `productLinks` for docs site links where possible

Where possible, we should be making sure that we're using the
`productLinks`' configuration for  the documentation site, especially
where self-hosted users may create a mirror of their docs[0].

To make sure we catch this in the future, we can introduce a custom
linting rule with Oxlint to enforce this.

Where we (currently) can't wire in the config, we can disable it against
that line.

[0]: https://www.jvt.me/posts/2024/11/19/renovate-private-docs/

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

* fixup! chore: ensure we use `productLinks` for docs site links where possible

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

* fixup! chore: ensure we use `productLinks` for docs site links where possible

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

---------

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
2026-06-18 08:55:27 +00:00
Sebastian Poxhofer 03baf6ee4a test(noNewURL): add new rule enforcing parseUrl() from 'lib/util/url.ts' (#43247)
* test(noNewURL): add new rule enforcing parseUrl() from 'lib/util/url.ts'

* replace newURL with parseUrl

* remove non-null assertions marks if appropiate

* test: add additional tests

* test: add additional tests and ignore where it makes sense

* implement suggestions

* test: further improve coverage

* apply suggestion
2026-05-13 16:23:10 +00:00
renovate[bot] c2aa761c1e chore(deps): update linters (main) (#41417)
* chore(deps): update linters

| datasource | package              | from   | to     |
| ---------- | -------------------- | ------ | ------ |
| npm        | @eslint/js           | 9.39.2 | 9.39.3 |
| npm        | eslint               | 9.39.2 | 9.39.3 |
| npm        | eslint-plugin-oxlint | 1.46.0 | 1.49.0 |
| npm        | oxlint               | 1.47.0 | 1.49.0 |
| npm        | typescript-eslint    | 8.55.0 | 8.56.0 |

* chore(deps): update linters

| datasource | package              | from   | to     |
| ---------- | -------------------- | ------ | ------ |
| npm        | @eslint/js           | 9.39.2 | 9.39.3 |
| npm        | eslint               | 9.39.2 | 9.39.3 |
| npm        | eslint-plugin-oxlint | 1.46.0 | 1.49.0 |
| npm        | oxlint               | 1.47.0 | 1.49.0 |
| npm        | typescript-eslint    | 8.55.0 | 8.56.0 |

* Radix rule has been deprecated

* fixup! Radix rule has been deprecated

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
2026-02-28 11:23:25 +00:00
Michael Kriese 99f4a76dc9 fix(got): normalize options (#41298) 2026-02-18 14:01:37 +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
Michael Kriese 9fe353adb4 test: add coverage (part1) (#40636) 2026-01-23 15:09:01 +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
RahulGautamSingh 76f911041a refactor: use named exports (#39196)
* use named exports

* fix test

* add missing imnport

* fix prettier
2025-11-10 12:00:35 +00:00
Michael Kriese a5f3956210 refactor: remove default radix from parseInt (#37489) 2025-08-13 15:36:30 +00:00
Rhys Arkins a0895e6c28 feat: log one warning for 401 github (#36235) 2025-06-01 09:13:56 +00:00
RahulGautamSingh 49fa1be464 feat(util): getEnv (#35161)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-05-06 18:37:28 +00:00
Sergei Zharinov db8dda2378 fix: Explicitly disable memCache when caching is switched on/off (#35060)
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
2025-03-30 08:02:36 +00:00
Michael Kriese 5897f3057d fix: refactor http (take 2) (#34558) 2025-02-28 17:17:09 +00:00
Michael Kriese 593a92655e feat: refactor http (#34550) 2025-02-28 14:40:04 +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
Sergei Zharinov 5c0628bf3b feat(host-rules): Support readOnly request matching (#28562)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-04-23 03:26:20 +00:00
Sergei Zharinov 8596967060 feat(http): Switch to pluggable HTTP cache implementation (#27966)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-03-19 16:34:05 +00:00
Sergei Zharinov c25804194d refactor(http): Remove unused HTTP etag caching implementation (#28000) 2024-03-18 13:58:31 +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
renovate[bot] cbef575a2c chore(deps): update linters to v6.20.0 (#26925)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-02-12 09:09:29 +00:00
Rhys Arkins 4bd6b27be4 fix(github): cache http response only for first page (#27031) 2024-02-03 11:04:58 +00:00
renovate[bot] 4c2ce97bb4 build(deps): update dependency prettier to v3.2.2 (#26755)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-01-21 08:20:41 +00:00
Sergei Zharinov 383bc11d4c refactor(http): Separate search and apply of host rules (#26067) 2023-12-01 12:00:20 +00:00
renovate[bot] e5cbbaaf09 build(deps): update dependency prettier to v3 (#23627)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
2023-11-07 17:12:01 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Tobias 80a81ce567 feat(platform/github): autodetect GitHub App username and commit email (#24231) 2023-09-05 07:30:00 +00:00
Sergei Zharinov 290b78d87d feat(http): Etag support (#22302) 2023-05-25 12:17:43 +00:00
renovate[bot] da29ed179c chore(deps): update dependency @types/luxon to v3.3.0 (#21418)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: RahulGautamSingh <rahultesnik@gmail.com>
2023-04-12 06:49:00 +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
renovate[bot] 9ff3946839 chore(deps): update dependency @types/parse-link-header to v2.0.1 (#20343)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: RahulGautamSingh <rahultesnik@gmail.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-02-11 13:16:43 +00:00
LordCranus 395e490d70 chore(http/github): log warning if Github secondary rate limit is hit (#20074) 2023-01-27 23:00:05 +01:00
RahulGautamSingh d869c946d1 refactor: reduce debug metadata (#18737) 2022-11-07 11:29:02 +00:00
RahulGautamSingh c56588eaba refactor: convert PlatformmId to union (#18458) 2022-11-01 14:46:09 +00:00
Rhys Arkins cdec83463c fix(http): improve error logging (#18454)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-10-21 10:14:45 +00:00
Rhys Arkins be10c29d17 fix(http): improve error handling (#17587)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-10-19 04:27:07 +00:00
renovate[bot] 5109f9b794 chore(deps): update dependency typescript to v4.8.4 (#17988)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2022-10-07 06:15:49 +00:00
Sergei Zharinov 3e3023fd5e refactor(http): Simplify base types (#18088) 2022-10-03 10:53:20 +02:00