Skip to content

Commit 7051960

Browse files
author
Lucas Mathis
committed
fix: bump axios to ~1.15.2 and harden debug logging against non-stringifiable values
1 parent b4c3f89 commit 7051960

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- The debug log helper no longer crashes when axios error fields return a non-primitive from `toString` or `Symbol.toPrimitive`.
10+
11+
### Security
12+
- Bumped `axios` to `~1.15.2` to address 13 high-severity advisories.
813

914
## [1.27.0] - 2026-04-27
1015
### Changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@types/node": ">=12.0",
2323
"adm-zip": "^0.5.16",
24-
"axios": "^1.7.4",
24+
"axios": "~1.15.2",
2525
"form-data": "^3.0.4",
2626
"loglevel": ">=1.6.2"
2727
},

src/utils.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,28 @@ import {
2222

2323
const logger = loglevel.getLogger('deepl');
2424

25+
// Stringify a value safely for logging. Default `${value}` interpolation
26+
// throws "Cannot convert object to primitive value" on objects whose
27+
// `[Symbol.toPrimitive]`/`toString`/`valueOf` returns an object instead of a
28+
// primitive (some axios error fields fall into this category in certain
29+
// releases). Fall back to JSON.stringify, and finally to a sentinel string.
30+
function safeStringify(value: unknown): string {
31+
try {
32+
return String(value);
33+
} catch {
34+
try {
35+
return JSON.stringify(value) ?? '<unprintable>';
36+
} catch {
37+
return '<unprintable>';
38+
}
39+
}
40+
}
41+
2542
function concatLoggingArgs(args?: object): string {
2643
let detail = '';
2744
if (args) {
2845
for (const [key, value] of Object.entries(args)) {
29-
detail += `, ${key} = ${value}`;
46+
detail += `, ${key} = ${safeStringify(value)}`;
3047
}
3148
}
3249
return detail;

0 commit comments

Comments
 (0)