Commit 72fb54d
committed
backup: #904 v8 - fail-closed on DynamoDB JSONL + fix stale godoc
Two findings on v7.
## Codex P2 v7: silent data loss on DynamoDB JSONL inputs
The decoder writes items/data-*.jsonl when --dynamodb-bundle-mode jsonl
is set, and the manifest records this as `dynamodb_layout: "jsonl"`.
The reverse encoder, however, only walks per-item files
(items/*.json, items/*/*.json) and silently skips every JSONL file.
Result: a JSONL dump round-trips through the encoder as an .fsm with
ONLY table metadata and ZERO items — a "successful" empty restore
artifact.
Fix:
- New ErrEncodeUnsupportedDynamoDBLayout sentinel.
- EncodeOptions gains DynamoDBBundleJSONL bool. validateEncodeOptions
rejects when DynamoDBBundleJSONL && Adapters.DynamoDB.
- CLI's buildEncodeOptions sets the field from
manifest.DynamoDBLayout == DynamoDBLayoutJSONL.
- CLI's run() maps the error to exit-2 (data-correctness, like the
HLC ceiling regression).
Guard fires only when DDB is in scope so a caller encoding ONLY
Redis/SQS/S3 with the flag accidentally set is unaffected; pinned by
TestEncodeSnapshotJSONLOnlyRejectedWhenDDBEnabled. Rejection path
pinned by TestEncodeSnapshotRejectsDynamoDBJSONLLayout.
When the encoder learns the JSONL layout (future milestone), this
field switches from a fail-closed guard to a layout selector.
## Claude v7 doc bug: ErrSelfTestLowerLastCommitTS comment is stale
The var comment at lines 17-22 was accurate after v4's doc fix
("EncodeSnapshot itself does NOT enforce this floor") but v7 added
validateEncodeOptions which DOES enforce it when ManifestLastCommitTS > 0.
Comment now describes both layers (CLI + library) and points at the
codex P2 v2 plus claude v3 history.
## Caller audit per CLAUDE.md semantic-change rule
- EncodeOptions gained DynamoDBBundleJSONL bool. CLI sets it from
manifest; existing same-package tests pass EncodeOptions{} so the
zero default (false) preserves their behavior. No legitimate caller
impacted.
- validateEncodeOptions split into validateEncodeOptions +
validateEncodeOptionsData to keep both under the cyclop threshold.
Pure refactor: identical control flow, same errors returned.
- run() gained a third errors.Is branch for the new sentinel; same
exit-2 mapping pattern as the prior two.
Tests + lint green.1 parent 9f69295 commit 72fb54d
3 files changed
Lines changed: 110 additions & 22 deletions
File tree
- cmd/elastickv-snapshot-encode
- internal/backup
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
294 | 297 | | |
295 | 298 | | |
296 | 299 | | |
| 300 | + | |
297 | 301 | | |
298 | 302 | | |
299 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
31 | 44 | | |
32 | 45 | | |
33 | 46 | | |
| |||
53 | 66 | | |
54 | 67 | | |
55 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
56 | 78 | | |
57 | 79 | | |
58 | 80 | | |
| |||
155 | 177 | | |
156 | 178 | | |
157 | 179 | | |
158 | | - | |
159 | | - | |
160 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
161 | 184 | | |
162 | 185 | | |
163 | 186 | | |
| |||
167 | 190 | | |
168 | 191 | | |
169 | 192 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 193 | + | |
174 | 194 | | |
175 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
176 | 203 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 204 | + | |
181 | 205 | | |
182 | 206 | | |
183 | 207 | | |
184 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
185 | 214 | | |
186 | 215 | | |
187 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
266 | 321 | | |
267 | 322 | | |
268 | 323 | | |
| |||
0 commit comments