AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 15 Bitcoin

Merge rust-bitcoin/rust-bitcoin#7014: Make source destructure official policy and apply it everywhere

Public commit record

What the developer wrote

Authored by Andrew Poelstra

91/100 · Strong
Merge rust-bitcoin/rust-bitcoin#7014: Make source destructure official policy and apply it everywhere

ad1906b2cd4c97e0108deb7d78b4d26d0a2e25cf docs: link the infallible error rule to its section (satsfy (Renato Britto))
c2dd4a55875837c9e1daf79fc9bc0572a0b7a247 docs: add error source destructure policy (satsfy (Renato Britto))
2c17c87d74644341eeb1a066edab2ef82d1c2f2a p2p: destructure FeatureDataError source impl (satsfy (Renato Britto))
8ffa7fde17ae60784e0816672630625951a4430a key_expression: destructure bip32 error source impls (satsfy (Renato Britto))

Pull request description:

A follow up of https://github.com/rust-bitcoin/rust-bitcoin/pull/6872#discussion_r4203301150

Add a new policy rule `P-ERROR-SOURCE`. An error with no inner error implements `source` by destructuring `self` and returning `None`. Adding a field later fails to compile at `source` instead of returning `None`.

The whole workspace already does this since the [sweep that introduced it](https://github.com/rust-bitcoin/rust-bitcoin/pull/6293), but nothing in the policy documents or enforces it. The consequence is that 3 posteriorly created types missed it. Fixed the two bip32 derivation errors in key_expression and `FeatureDataError` in p2p.

The last commit adds an internal link to `From<Infallible>` rule, which is not necessary but makes the document better IMO.


ACKs for top commit:
apoelstra:
ACK ad1906b2cd4c97e0108deb7d78b4d26d0a2e25cf; successfully ran local tests
tcharding:
ACK ad1906b2cd4c97e0108deb7d78b4d26d0a2e25cf


Tree-SHA512: af1a126b46de3059999864b0fff62617d672b29a80981104ccfca85317d4369060ece9a4caf8b78be83e19d173fef24e8400284e3f13b4c53aebeecba1381efe
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This is a code-quality and documentation patch. It adds a project policy saying that when a Rust error type has no underlying cause, the `source` method should explicitly destructure the error's fields before returning `None`. This makes future additions to the error type fail to compile unless `source` is updated, preventing accidental omissions. The patch also applies this style to three recently-added error types. There is no runtime behavior change and no security vulnerability is fixed or introduced.

Recommended action

No security action required. Treat as normal code-style/policy maintenance.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 10/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.