)]}'
{
  "commit": "2a001d466f6b71a917319a1db41f99860e16e269",
  "tree": "6bf4efe725d4171ddf44ed990623f03471040c5e",
  "parents": [
    "2cd14d171b7cb645c1d802e3d3044fddae4d5fc2"
  ],
  "author": {
    "name": "Aditya Jha",
    "email": "aditya.jha8969@gmail.com",
    "time": "Fri Aug 28 01:05:19 2026"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Fri Aug 28 01:05:19 2026"
  },
  "message": "fix(table): return error instead of fatalpanic when opening a corrupt sst (#2333)\n\n**Description**\n\nFixes [#2201](https://github.com/dgraph-io/badger/issues/2201) \n\n`db.Open()` crashes with a `runtime.fatalpanic` when an SSTable\u0027s footer\nis corrupted (e.g. zeroed), instead of returning an error.\n\nLooking at the stack trace of issue description, it looks like following\ncould be the reason for runtime termination,\n\nAn SST footer is laid out as `[index][indexLen][checksum][checksumLen]`,\nwith the two lengths stored as 4-byte big-endian values. When the footer\nis zeroed, `checksumLen` and `indexLen` both read as `0`, so we read\nempty checksum and index bytes. The empty protobuf checksum unmarshals\nto `Sum \u003d 0`, and the CRC32C of an empty index is also `0`, so the `0 \u003d\u003d\n0` verification passes. The code then parses the empty index as\nflatbuffers and reads an out-of-bounds offset into a slice, which\npanics. `initBiggestAndSmallest` catches that panic, collects debug\ninfo, then deliberately re-panics — and that re-panic escapes the\ntable-loading goroutine in `newLevelsController` (which has no\n`recover()`), so the runtime terminates the process.\n\nChanges:\n- `table/table.go`: `initBiggestAndSmallest` returns an error (instead\nof re-panicking) after collecting debug info, and `initIndex` validates\nthe footer\u0027s `checksumLen`/`indexLen`, rejecting `\u003c\u003d 0` (an empty\nchecksum/index false-passes the `0 \u003d\u003d 0` checksum check and then panics\nparsing empty flatbuffers) and `\u003e\u003d tableSize` (the length can\u0027t describe\na region as large as the whole file — it would make the footer\u0027s read\noffset negative and slice out of bounds).\n- `levels.go`: added a `recover()` in the table-loading goroutine as a\nsafety net for any panic that still escapes the table package.\n\n**Checklist**\n\n- [x] Code compiles correctly and linting passes locally\n- [x] Tests added for new functionality, or regression tests for bug\nfixes added as applicable\n\n---------\n\nCo-authored-by: Matthew McNeely \u003cmatthew.mcneely@gmail.com\u003e\nCo-authored-by: Claude Opus 5 (1M context) \u003cnoreply@anthropic.com\u003e",
  "tree_diff": [
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "04ac7000a4e2e2949c26142cc71bd48bb5fca031",
      "new_mode": 33188,
      "new_path": "db_corrupt_test.go"
    },
    {
      "type": "modify",
      "old_id": "e951c8a1153571520c20552d31b0c95daf8d5e7c",
      "old_mode": 33188,
      "old_path": "levels.go",
      "new_id": "de4cfc037de7b2dbfddcbdaaa5d99c2894ef42a4",
      "new_mode": 33188,
      "new_path": "levels.go"
    },
    {
      "type": "modify",
      "old_id": "39ab14903d9552c95b3b235beefd89983f6c4e15",
      "old_mode": 33188,
      "old_path": "levels_test.go",
      "new_id": "f20e592fbb7086be759c3c3f72cc485b27d4359b",
      "new_mode": 33188,
      "new_path": "levels_test.go"
    },
    {
      "type": "modify",
      "old_id": "a9c179804520b8d93ad5ff69aed9decf1902235a",
      "old_mode": 33188,
      "old_path": "table/builder_test.go",
      "new_id": "cb073a58cd8cae7467854df92004032b688a3b56",
      "new_mode": 33188,
      "new_path": "table/builder_test.go"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "4bfae847ea0743b15ab30ecbbcb793fb79a934c6",
      "new_mode": 33188,
      "new_path": "table/initindex_test.go"
    },
    {
      "type": "modify",
      "old_id": "f671333dbfcfb3b46026a93d9b1abf4678421d0b",
      "old_mode": 33188,
      "old_path": "table/table.go",
      "new_id": "7c5c5e66e0df9a0d16283196a8f15cec17028c5f",
      "new_mode": 33188,
      "new_path": "table/table.go"
    }
  ]
}
