Skip to content

fix(core): keep the cause of a persisted deterministic error - #6792

Open
lx3133584 wants to merge 1 commit into
graphprotocol:masterfrom
lx3133584:fix/persisted-store-error-cause
Open

lx3133584 wants to merge 1 commit into
graphprotocol:masterfrom
lx3133584:fix/persisted-store-error-cause

Conversation

@lx3133584

Copy link
Copy Markdown

What

A fatal store error reaches the operator as Failed to transact block operations with no indication of what failed. The persisted message should carry both the transaction context and the original cause.

Why

ProcessingError::detail wraps a deterministic error's cause in an anyhow::Error:

ProcessingError::Deterministic(Box::new(anyhow!("{e}").context(ctx.to_string())))

The runner then formats the whole enum with {:#} before persisting it (runner/mod.rs). The variant's renderer was #[error("{0}")], which hands the wrapper to Formatter::Display rather than Formatter::Debug-style alternates, so the output ends at anyhow's outermost message and never walks into the source chain.

StoreError::Unknown already formats its cause with {0:#}, so this brings the deterministic variant in line with the rest of the error types.

Change

#[error("{0}")] → #[error("{0:#}")] on ProcessingError::Deterministic.

Display impls that ignore the alternate flag are unaffected. That covers SubgraphError and the StoreError variants that write a fixed message.

Test

a_deterministic_error_keeps_its_cause_under_the_context builds a deterministic error with a synthetic store cause, runs it through detail(), and asserts the {:#} rendering contains both halves:

Failed to transact block operations: synthetic constraint violation

Before the change it fails with left: "Failed to transact block operations". After it, it passes.

cargo test -p graph-core --lib subgraph:: — 7 passed.
cargo test -p graph-core --lib — 13 passed, 1 failed. The failure is polling_monitor::ipfs_service::test::cat_file_in_folder, which needs a live IPFS service and fails the same way on an untouched checkout.

cargo fmt -p graph-core --check clean, cargo clippy -p graph-core --lib has no warning for the changed file.

Closes #6791

A fatal store error reached the operator as `Failed to transact block
operations` alone. `detail()` wraps the cause in an `anyhow::Error`, and
`ProcessingError::Deterministic` rendered it with `{0}`; the runner then
formats the whole enum with `{:#}` for persistence, so `anyhow`'s
alternate formatting stopped at the display message instead of walking
into the source chain. The diagnostic that identifies the store problem,
such as `synthetic constraint violation`, was discarded before it was
written.

The variant now renders with `{0:#}`. Those `Display` impls that ignore
the alternate are unaffected, and `StoreError::Unknown` already formats
its cause that way.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Persisted deterministic store error loses its cause when adding transaction context

1 participant