Commit fb46e04
authored
fix(cli): error messages in env/ + constants/ + sea-build scripts (#1258)
* fix(cli): align env/ + constants/ + build-script error messages with 4-ingredient strategy
Rewrites runtime and build-time error messages for the build-inlined
version/checksum pipeline to follow the What / Where / Saw vs. wanted /
Fix strategy from CLAUDE.md.
Sources (runtime):
- env/coana-version.mts, env/sfw-version.mts (2 getters),
env/socket-basics-version.mts, env/socket-patch-version.mts,
env/trufflehog-version.mts, env/trivy-version.mts,
env/opengrep-version.mts, env/pycli-version.mts — 9 "INLINED_X
not found" errors. Each now names the exact env var, the
bundle-tools.json path it comes from, and how to rebuild
(`pnpm run build:cli`).
- env/checksum-utils.mts — parseChecksums() and requireChecksum()
now show the exact JSON.parse error or the list of known assets
so you can see what was in vs. out of the map.
- constants/paths.mts — getSocketRegistryPath() now enumerates
every env var the app-data lookup checks (HOME, USERPROFILE,
LOCALAPPDATA, XDG_DATA_HOME) so a cold environment tells you
which to set.
Sources (build-time scripts, same message style for consistency):
- scripts/sea-build-utils/downloads.mts — 3 checksum-missing
errors in the SEA build path, each now names the bundle-tools.json
key and tells you to run `pnpm run sync-checksums`.
No tests pinned these messages (only dist/cli.js — unchecked-in
build output).
Follows strategy from #1254. Continues #1255, #1256, #1257.
* chore(cli): harden (e as Error) casts to safe stringify
Switch `(e as Error).message` to `e instanceof Error ? e.message : String(e)` so that when a non-Error value is thrown (strings, objects, null) the error message stays informative instead of becoming 'undefined'.
Same fix as applied to #1260 (iocraft.mts) after Cursor bugbot flagged the pattern on that PR.
* fix(cli): address Cursor bugbot findings on checksum error messages
Two issues flagged by Cursor bugbot on #1258:
1. (Low) parseChecksums() built the env var name as
`INLINED_${toolName.toUpperCase()}_CHECKSUMS`. When toolName has
spaces (e.g. 'Socket Patch'), toUpperCase() produces 'SOCKET PATCH'
→ 'INLINED_SOCKET PATCH_CHECKSUMS' — not a valid env var name. The
real env var is INLINED_SOCKET_PATCH_CHECKSUMS.
2. (Low) Both parseChecksums() and requireChecksum() embedded
`tools.${toolName}.checksums` to reference bundle-tools.json paths,
but toolName is the display name (PyCLI, OpenGrep, Socket Patch)
not the case-sensitive JSON key (socketsecurity, opengrep,
socket-patch).
Both came from the same root cause: I treated the display-name
parameter as if it were a canonical identifier. Fix: reword the
messages to just name the tool in prose ('inlined checksums for X',
'X has no SHA-256 for Y') and point at the 'matching entry in
bundle-tools.json' instead of inventing a wrong path. Keeps the
4-ingredient structure (what/where/saw/fix) without claiming
identifiers that don't exist.
Caught by #1258 bugbot review.
* chore(cli): use joinAnd from @socketsecurity/lib/arrays for error lists
Switch the 4 `Object.keys(x).join(', ')` calls in error messages on
this branch to `joinAnd(Object.keys(x))` so they render as human
prose (e.g. 'a, b, and c') instead of machine-y comma-joins.
Sites:
- src/env/checksum-utils.mts: requireChecksum known-assets list
- scripts/sea-build-utils/downloads.mts: 3 missing-checksum errors
(external tools, socketsecurity wheel, socket-basics archive)
No behavior change — just uses the fleet helper consistently.
* fix(cli): use bracket notation for hyphenated tool keys in error message
Cursor flagged the checksum-missing error in downloads.mts: it used
\`tools.\${toolName}.checksums\` (dot notation) which produces an
invalid JSONPath like \`tools.socket-patch.checksums\` when toolName
is hyphenated. The socket-basics site a few hundred lines down already
uses bracket notation for the same reason; make this one match.
Reported on PR #1258.1 parent edbb30d commit fb46e04
11 files changed
Lines changed: 21 additions & 20 deletions
File tree
- packages/cli
- scripts/sea-build-utils
- src
- constants
- env
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
335 | | - | |
336 | | - | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
477 | | - | |
| 476 | + | |
478 | 477 | | |
479 | 478 | | |
480 | 479 | | |
| |||
544 | 543 | | |
545 | 544 | | |
546 | 545 | | |
547 | | - | |
548 | | - | |
| 546 | + | |
549 | 547 | | |
550 | 548 | | |
551 | 549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | | - | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
0 commit comments