`Sibit::Blockchain#height` returns nil on missing `height` field while siblings raise
#268 opened on Jun 23, 2026
Repository metrics
- Stars
- (27 stars)
- PR merge metrics
- (PR metrics pending)
Description
Sibit::Blockchain#height at lib/sibit/blockchain.rb:46-53 returns nil whenever the blockchain.info/rawblock/<hash> response body lacks a height field, while every sibling implementation under the same contract raises Sibit::Error in that case:
Sibit::Btc#height(lib/sibit/btc.rb:70-79) raises"The block #{hash} found but the height is absent"whendata['height']is nil.Sibit::Sochain#height(lib/sibit/sochain.rb:46-55) raises"The block #{hash} found but the height is absent"whendata['block_no']is nil.Sibit::Bitcoinchain#heightandSibit::Cex#heightraiseSibit::NotSupportedErroroutright.
The silent return is invisible to Sibit::FirstOf and Sibit::BestOf, which only fall back on Sibit::Error/Sibit::NotSupportedError. A nil height therefore short-circuits the consensus chain instead of escalating to the next provider, and downstream Integer(h) calls or arithmetic on the result crash later with a less informative TypeError.
The fix is one guard line: raise Sibit::Error, "The block #{hash} found but the height is absent" when h.nil?, mirroring the sibling adapters. A regression test under test/test_blockchain.rb stubbing a rawblock response without height and asserting the raise would lock the contract in place.