Skip to content

fix(indexer): validate bme price attribute as dec string - #3605

Merged
baktun14 merged 1 commit into
feat/indexer-scaffold-chain-indexer-appfrom
fix/indexer-validate-bme-price-dec
Aug 18, 2026
Merged

fix(indexer): validate bme price attribute as dec string#3605
baktun14 merged 1 commit into
feat/indexer-scaffold-chain-indexer-appfrom
fix/indexer-validate-bme-price-dec

Conversation

@baktun14

Copy link
Copy Markdown
Contributor

Why

Part of CON-813. A post-merge CodeRabbit review of #3603 flagged that the BME price attribute is the one numeric event attribute written into the numeric(38,18) ledger columns without validation. The proto field is a free-form string, so a malformed value would abort the whole batch transaction and retry-loop the indexer on that height range. That breaks the deriver's own rule that a malformed event degrades to a parse warning instead of halting the block.

What

  • Validate price with the same Dec-string check collateral_ratio already uses. A bad price now becomes a parse warning like every other malformed attribute.
  • Document that widening the scanned BME event-type set shifts replay ordinals and would duplicate bme_status_changes rows.
  • Add the specs the review found missing: non-Dec price, absent price mapping to null, unquoted legacy status attributes, and malformed coins_to_burn on a canceled record.

A non-numeric price in a bme coin attribute previously flowed unchecked
into the numeric(38,18) ledger columns, aborting the whole batch
transaction instead of degrading to a parse warning like every other
malformed attribute. Also documents that widening the scanned bme
event-type set shifts replay ordinals.
@baktun14
baktun14 requested a review from a team as a code owner August 18, 2026 06:02
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 16e257f5-0de8-4e2e-8c18-369db3aa605d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — this is a narrowly scoped, well-tested fix.

Extended reasoning...

Overview

This PR adds Dec-string validation to the BME price attribute in parseCoinPrice (apps/chain-indexer/src/bme/bme-deriver.ts), mirroring the existing validation already applied to collateral_ratio. Previously, any non-Dec-string price value (or malformed proto attribute) would pass through unchecked and later fail when written into a numeric(38,18) database column, aborting the whole batch transaction and causing the indexer to retry-loop on that height range. Now a malformed price causes parseCoinPrice to return undefined, which the caller treats as a malformed-coin condition, degrading gracefully to a parse warning consistent with how every other malformed BME attribute is already handled. The PR also adds a doc comment clarifying an existing ordinal-stability caveat, and backfills several previously-missing spec cases (non-Dec price, absent price, unquoted legacy status attributes, malformed coins_to_burn).

Security risks

None. This is purely a defensive-parsing fix for indexer-internal event decoding; no user input, auth, or crypto surfaces are touched. If anything, tightening validation here reduces risk (previously a malformed value could propagate into a numeric DB write and abort a batch).

Level of scrutiny

Low-to-moderate. This is a small, self-contained fix (single function change) to internal blockchain-event parsing logic in a non-critical-path indexer, following an established pattern in the same file (isDecString already existed and was used for collateral_ratio). The change is well covered by new unit tests that exercise exactly the scenarios described in the PR (non-Dec price → warning, absent price → null, legacy unquoted status attrs, malformed coins_to_burn → warning), and I traced asString/isDecString/parseJsonRecord to confirm the null-vs-malformed distinction is preserved correctly.

Other factors

No prior review threads or outstanding comments to address (the only existing comment is an automated CodeRabbit skip notice). The diff is small (size: S label) and touches only one source file plus its spec file. I found no issues beyond what the bug-hunting system already ruled out.

@baktun14
baktun14 merged commit 1f618e7 into feat/indexer-scaffold-chain-indexer-app Aug 18, 2026
7 checks passed
@baktun14
baktun14 deleted the fix/indexer-validate-bme-price-dec branch August 18, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant