Commit ef2fbe2
chore(node-client): harden existing platform implementation (#1403)
Hardens the Node platform layer landed in #1393, ahead of the
client-side SDK implementation that builds on it. First atomic in the
node-client port stack.
- **NodeStorage**: log (no longer swallow) flush errors; validate/log on
malformed cache reads and ignore non-string cache values; write the temp
file via an exclusive `wx` open so the write cannot be redirected
through a symlink; warn when `getNodeStorage` is called with a
`localStoragePath` that differs from the process singleton's.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes on-disk cache semantics and filesystem write behavior; low
blast radius but incorrect handling could affect flag persistence or
local file security.
>
> **Overview**
> Hardens the Node client **platform** layer around flag disk cache and
tightens related tests.
>
> **`NodeStorage`** now treats a missing cache file as a normal first
run (no warning, no empty rewrite). Malformed or unreadable cache files
trigger a **warn** and recovery write; loaded JSON must be a plain
object and only **string** values are kept. Persists via an exclusive
**`wx`** temp open (after removing any existing temp path) so writes
cannot follow a symlink planted on the temp file path.
**`getNodeStorage`** records the first `localStoragePath` and **warns**
if a later call passes a different path; **`resetNodeStorage`** clears
that path tracking too.
>
> **Tests** cover first-run behavior, malformed JSON warnings,
non-string cache entries, symlink safety, singleton path mismatch
warnings, and **`NodeInfo`** no longer pins the SDK **version** string
in expectations.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1962f54. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>1 parent c012e57 commit ef2fbe2
3 files changed
Lines changed: 115 additions & 10 deletions
File tree
- packages/sdk/node-client
- __tests__/platform
- src/platform
Lines changed: 4 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
73 | 132 | | |
74 | 133 | | |
75 | 134 | | |
| |||
104 | 163 | | |
105 | 164 | | |
106 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | | - | |
53 | | - | |
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
| |||
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
| 73 | + | |
65 | 74 | | |
66 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
67 | 87 | | |
68 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
69 | 98 | | |
70 | 99 | | |
71 | 100 | | |
| |||
142 | 171 | | |
143 | 172 | | |
144 | 173 | | |
| 174 | + | |
145 | 175 | | |
146 | 176 | | |
147 | 177 | | |
148 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
149 | 184 | | |
150 | 185 | | |
151 | 186 | | |
152 | 187 | | |
153 | 188 | | |
154 | 189 | | |
155 | 190 | | |
| 191 | + | |
156 | 192 | | |
0 commit comments