Commit 145a912
committed
backup: #904 v9 - stat InputRoot + fix godoc attribution
Two findings on v8.
## Codex P2 v8: silent empty-restore on missing/stale InputRoot
validateEncodeOptions only rejected the empty string. A library caller
that passed a typo'd or deleted InputRoot would fan-out into every
enabled adapter, each treating its missing top-level subdirectory as
a no-op. Result: a "successful" header-only .fsm — exactly the silent
empty-restore artifact the encoder is supposed to fail closed against.
CLI callers don't hit this path (they open MANIFEST.json under
InputRoot first), but the library entrypoint is now a real surface,
so the guard belongs in EncodeSnapshot itself.
Fix: validateEncodeOptions now os.Stats InputRoot after the empty-
string check, rejecting non-existent paths (wraps the stat error)
and regular files (returns a typed error). Both rejection paths run
before any byte is written and before any adapter is invoked.
Pinned by TestEncodeSnapshotRejectsMissingInputRoot (subtests:
non-existent path; regular file). Existing TestEncodeSnapshot
LibraryRoundTrip + the manifest-floor tests use t.TempDir(), which
is a directory, so they continue to pass.
## Claude v8 doc bug: EncodeSnapshot godoc attributed to wrong symbol
The EncodeSnapshot doc block sat directly above the
validateEncodeOptions doc block with no blank line between them, so
godoc tooling (and gopls) attributed the entire merged comment to
validateEncodeOptions. EncodeSnapshot — the only exported function
in this file — had no godoc at all.
Fix: relocate the EncodeSnapshot doc block to immediately precede
`func EncodeSnapshot`, separated from validateEncodeOptionsData by
a blank line. Content unchanged; only the location moved.
## Caller audit per CLAUDE.md semantic-change rule
- validateEncodeOptions gained a fail-closed pre-condition (stat +
IsDir). All in-tree callers pass either t.TempDir() (directory) or
a real backup root (directory). No legitimate caller is impacted;
bad-input callers now surface a typed error instead of silently
producing a header-only .fsm — strictly safer.
- No exported signature or error semantics changed beyond the new
rejection path.
Tests + lint green.1 parent 72fb54d commit 145a912
2 files changed
Lines changed: 94 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | 150 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
184 | 155 | | |
185 | 156 | | |
186 | 157 | | |
187 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
188 | 172 | | |
189 | 173 | | |
190 | 174 | | |
| |||
214 | 198 | | |
215 | 199 | | |
216 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
217 | 230 | | |
218 | 231 | | |
219 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
214 | 262 | | |
215 | 263 | | |
216 | 264 | | |
| |||
0 commit comments