fsck should accept stash objects - #11298
Conversation
dolt fsck fails when a repository contains a stash because the stash ref (StashRefType) is treated as a commit-pointing ref, so its StashList (SLST) object is validated as a commit (DCMT). This test asserts fsck passes cleanly with a stash present and that the stash survives the check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…11292) fsck treated a stash ref (StashRefType) as a commit-pointing ref, so the StashList (SLST) address it points to was fed into the commit DAG walk and parsed as a commit (DCMT), failing with "incorrect file ID: expected DCMT, got SLST" for any repo containing a stash. A stash ref points to a StashList whose entries each reference the commit the stash was based on (a commit) and the stashed working root (a root value). Resolve the stash list into those objects: feed the head commit into the commit DAG walk (as tags already do) and validate the stashed working root as a tree root. The working root is only reachable through the stash, so it would otherwise never be walked. Generalize Errs.CmtAppendF into refAppendF(kind, ownerHash, ...) so tree errors under a stash root are labeled "::stash:" rather than "::commit:"; CmtAppendF delegates with kind "commit" and its output is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@macneale4 DOLT
|
|
@macneale4 DOLT
|
|
@macneale4 DOLT
|
|
PR #11293 was a sound minimal fix and should remain closed as superseded. However, before #11298 is merged, I think two integrity-handling issues should be addressed:
Also on reporting, the summary now says that its reachability count includes stashes, but the stash-list and individual stash objects themselves are not added to that count. It would be worth adding corrupted-stash cases for the two issues above, because the current happy-path test does not exercise the new integrity-validation behavior. |
|
Thanks for your input @0x687931 re 1: fair point re 2: this is way beyond what fsck can do. All addresses in the data schema could conceivably point at incorrect object types, but the application code is responsible to ensure that doesn't happen. FSCK would need to be aware of every object relation type to verify all of them, and that's never been in scope. To have a valid address to randomly be corrupted into a different valid address is very unlikely. It's far more likely that such a situation would arise as the result of a bug in the application code. Adding more tests is more work than it's worth. creating corrupted databases and actually a fair amount of work. We are actually far better served with real examples of corruption from the wild. |
resolveStashRefs read the stash list via datas.GetHashListFromStashList, whose getStashListOrdered swallows the address-map iteration error and can leave nil entries; a damaged stash list (e.g. a non-numeric address-map key) then nil-dereferences and crashes the process. fsck exists to inspect possibly-corrupt repositories, so this must be reported, not fatal. Walk the stash list address map directly instead, checking the IterAll error, and read each stash through resolveStash which reports bad file IDs, missing objects, and malformed address fields as integrity errors while continuing the scan. Adds a unit test that resolves a corrupt stash list (the input that panics the old helper) and asserts it is handled without panicking. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You’re right 😜 I was narrowly looking at my problem
…On Tue, 14 Jul 2026 at 9:10 am, Neil Macneale IV ***@***.***> wrote:
*macneale4* left a comment (dolthub/dolt#11298)
<#11298 (comment)>
Thanks for your input @0x687931 <https://github.com/0x687931>
re 1: fair point
re 2: this is way beyond what fsck can do. All addresses in the data
schema could conceivably point at incorrect object types, but the
application code is responsible to ensure that doesn't happen. FSCK would
need to be aware of every object relation type to verify all of them, and
that's never been in scope. To have a valid address to randomly be
corrupted into a different valid address is very unlikely. It's far more
likely that such a situation would arise as the result of a bug in the
application code.
Adding more tests is more work than it's worth. creating corrupted
databases and actually a fair amount of work. We are actually far better
served with real examples of corruption from the wild.
—
Reply to this email directly, view it on GitHub
<#11298?email_source=notifications&email_token=AGLTHGNQZS4LVVE7ZM37SHL5EVT5HA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJWGM3DQMZZGM22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4963683935>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGLTHGKZZZHNGASG33FKJV35EVT5HAVCNFSNUABFKJSXA33TNF2G64TZHMYTSOBWHAZTKNZUHNEXG43VMU5TIOBXG43DONZZG442C5QC>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@macneale4 DOLT
|
| // Because fsck must tolerate corrupt repositories, the stash list address map is walked directly rather than via the | ||
| // datas stash helpers, which assume well-formed entries and can panic on damaged data. Any problem reading the list or | ||
| // its entries is appended to errs and skipped rather than aborting the scan. | ||
| func resolveStashRefs(ctx context.Context, cs chunks.ChunkStore, ns tree.NodeStore, stashListAddr hash.Hash, refName string, errs *Errs) (headCommits []hash.Hash, stashRoots []hash.Hash) { |
There was a problem hiding this comment.
Isn't this similar to the checks getRawReferencesFromStoreRoot does, is there a possibility to deduplicate?
The store-root reader and the stash-list reader both parsed an embedded serialized AddressMap the same way: decode the node, verify the ADRM file ID, and build the prolly.AddressMap. Extract that into addressMapFromBytes and call it from both getRawReferencesFromStoreRoot and resolveStashRefs. Addresses review feedback on PR #11298. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@macneale4 DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
fixes: #11292