Repository navigation
Commit 02df892
fix(logger): Keep falsy causes and literal % in error messages (#1779)
This fixes the Warden findings that were posted on #1773 after it
merged.
- **Falsy causes:** `formatError` showed a cause only when it was
truthy, so `new Error("x", { cause: 0 })` printed just `x`. It now shows
the cause whenever the error has one (`0`, `""`, `false`, `null`,
`undefined`), as `util.inspect` does.
- **An error as the first argument:** `formatMessage` turned errors into
strings before calling `util.format`, so an error passed first became
the format string. `logger.info(new Error("Failed for %s"), "extra")`
printed `Failed for extra`. The `%s` now stays literal and the remaining
arguments are added after it, as `console.log` does.
- **Craft `minVersion`:** raised from 2.33.0 to 3.5.0. The logger
workspace uses `{{workspaceName}}` and `{{packageSimpleName}}`, and
Craft only resolves those from 3.5.0 onward. The release workflow's
`getsentry/craft@v3` already installs 3.5.0. Warden said the
placeholders are left unresolved, which is wrong for the release
workflow, but an older local Craft would have left them as literal text
without any error. This raises the minimum for every workspace in this
repository.
Tests cover each falsy cause and an error message containing `%s`. For
other output, the build is byte-identical to `main` across about 24,600
formatted records.
<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A052a28796a4c37b4b8b5f916 -->
--
[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A052a28796a4c37b4b8b5f916/?project=4510944073809921)
<!-- junior-session-footer:end -->
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <126780+BYK@users.noreply.github.com>1 parent 34c1ceb commit 02df892
3 files changed
Lines changed: 35 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
| 60 | + | |
| 61 | + | |
63 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
471 | 498 | | |
0 commit comments