mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
312c380926
* fix(util/http): make the legacy `headers` getter configurable Every other property defined on `HttpError.prototype` in this file is `configurable`, but `headers` was not. That makes the module fail with `TypeError: Cannot redefine property: headers` whenever a test resets the module registry and re-imports anything that pulls in `got.ts`. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * test(manager/pre-commit): cover the suppress-warning env var `defaultConfig.prBodyNotes` drops the unsupported-manager warning when `RENOVATE_X_SUPPRESS_PRE_COMMIT_WARNING` is set. Since the value is computed at module load, the new spec resets the module registry and re-imports the manager with the variable stubbed. The `istanbul ignore next` on that arm is dropped because the branch is now exercised. Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> * refactor(manager): remove unreachable fallbacks Drop three defensive fallbacks that can never be taken: - `docker-compose`: `config.services ?? config` always yields an object, so the `|| {}` guard behind it is dead - `git-submodules`: `git.raw()` resolves to a string, so the `?? ''` never applies - `maven`: the only site that builds a `MavenProp` always passes a `packageFile` string, so narrow the type and drop the `?? undefined` Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io> --------- Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io>
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { RequestError as HttpError } from 'got';
|
|
import { parseUrl } from '../url.ts';
|
|
|
|
// TODO: remove when code is refactored (#9651)
|
|
|
|
Object.defineProperty(HttpError.prototype, 'statusCode', {
|
|
get: function statusCode(this: HttpError) {
|
|
return this.response?.statusCode;
|
|
},
|
|
configurable: true, // required by azure tests
|
|
});
|
|
|
|
Object.defineProperty(HttpError.prototype, 'body', {
|
|
get: function body(this: HttpError): unknown {
|
|
return this.response?.body;
|
|
},
|
|
set: function body(this: HttpError, value: unknown): void {
|
|
if (this.response) {
|
|
this.response.body = value;
|
|
}
|
|
},
|
|
configurable: true,
|
|
});
|
|
|
|
Object.defineProperty(HttpError.prototype, 'headers', {
|
|
get: function headers(this: HttpError) {
|
|
return this.response?.headers;
|
|
},
|
|
configurable: true,
|
|
});
|
|
|
|
Object.defineProperty(HttpError.prototype, 'url', {
|
|
get: function url(this: HttpError) {
|
|
return this.response?.url;
|
|
},
|
|
configurable: true,
|
|
});
|
|
|
|
Object.defineProperty(HttpError.prototype, 'host', {
|
|
get: function url(this: HttpError) {
|
|
const urlStr = this.response?.url;
|
|
const url = urlStr ? parseUrl(urlStr) : null;
|
|
return url?.host;
|
|
},
|
|
configurable: true,
|
|
});
|
|
|
|
export type GotLegacyError<E = unknown, T = unknown> = HttpError & {
|
|
statusCode?: number;
|
|
body: {
|
|
message?: string;
|
|
errors?: E[];
|
|
};
|
|
headers?: Record<string, T>;
|
|
};
|