← Back to Pull requests

Return an error instead of panicking on a short revision key #512

Merged
arpitjain099 merged 2 files (61 lines) on Aug 19, 2026 14:19 UTC
View on GitHub
arpitjain099 arpitjain099 commented on Aug 08, 2026 07:34 UTC
Author

bytesToRev length-checks only the tombstone byte. The two reads above it are unguarded, so any entry in the key bucket shorter than 17 bytes takes the process down:

panic: runtime error: slice bounds out of range [:8] with capacity 5
github.com/etcd-io/auger/pkg/data.bytesToRev(...)
	pkg/data/data.go:496
github.com/etcd-io/auger/pkg/data.walk.func1(...)
	pkg/data/data.go:440
main.main()
	main.go:26
### CLI EXIT CODE: 2 ###

There is no recover() anywhere in the non-test code, so this is a hard abort rather than an error. It matters because it fires on exactly the input auger exists to handle: a truncated or damaged database.

This is the same shape as #365, which was the nil-bucket panic one line away in the same walk callback. I followed the fix from 737ef47 deliberately, so the error string matches bucketOrError's style and the tests use the existing createTestDB helper.

After the change:

Error: invalid etcd boltdb: revision key must be at least 17 bytes, got 5

exit code 1, and a real fixture database still analyzes normally.

Two call sites are covered, since both can reach it. walk handles the key bucket, and getCompactRevision reads finishedCompactRev from the meta bucket where the existing guard is len != 0 rather than a length floor. There is a test for each, and both panic without the fix.

While in there I also switched the tombstone read to the markBytePosition and markTombstone constants that were already declared next to revBytesLen but unused.

bytesToRev is unexported and the signature change is contained to those two callers. walk's exported behaviour is unchanged, since it already returned an error.

go build ./..., gofmt and go test ./pkg/... are clean.

Diff: 61 lines (+53 / -8) across 2 files Reviewer: siyuanfoundation Review duration: 16244m
All Vouch review confidence checks passed
Residual risk 0.09 = Change Risk (0.29) × (1 − Review Confidence (0.70)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.29 · 61 lines diff across 2 files
0.29
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.55 · 4 substantive comment(s)
0.55
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
70%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.247
Real PR Conversation Timeline
6 items
siyuanfoundation siyuanfoundation commented on Aug 10, 2026 14:32 UTC
Contributor

/ok-to-test

siyuanfoundation siyuanfoundation commented on Aug 10, 2026 15:17 UTC
Contributor

/lgtm

Thanks @arpitjain099 for fixing this!

siyuanfoundation siyuanfoundation commented on Aug 10, 2026 15:17 UTC
Contributor

/cc @hwdef

siyuanfoundation siyuanfoundation approved these changes on Aug 19, 2026 14:19 UTC
Approved Reviewer

Approved these changes.

kubernetes-prow[bot] kubernetes-prow[bot] commented on Aug 19, 2026 14:19 UTC
Bot

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: <a href="https://github.com/etcd-io/auger/pull/512#" title="Author self-approved">arpitjain099</a>, <a href="https://github.com/etcd-io/auger/pull/512#pullrequestreview-4973163714" title="Approved">siyuanfoundation</a>

The full list of commands accepted by this bot can be found here.

The pull request process is described here

<details >
Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [siyuanfoundation]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Assignees
    arpitjain099 arpitjain099
    Labels
    risk: low confidence: 70.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 29.1% (LOW) · Higher = larger blast radius
    29.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 70.3% · Lower = rushed or shallow review
    70.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.7% · Safe to merge
    8.7%
    Repository