Skip to content

refactor!: propagate errors instead of panicking - #1845

Merged
mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:nulls-must-error-handling
Sep 15, 2026
Merged

mbrandenburger merged 1 commit into
hyperledger-labs:mainfrom
mbrandenburger:nulls-must-error-handling

Conversation

@mbrandenburger

Copy link
Copy Markdown
Member

Summary

  • utils.Must/utils.MustGet turned errors into panics at four call sites on the node-startup / store-construction path (newKVS, GetPersistenceName, and two GetTableNames functions), even though every enclosing function already returned an error. They now return the error instead of crashing the process.
  • escapeForTableName also panicked on channel names containing digits, a legal Fabric channel name, since it validated against ^[a-zA-Z_]+$. That's fixed too, so the existing wrapped error at channelprovider.go surfaces instead of a crash.
  • Wrapped errors.Wrapf at the entry points that would otherwise lose context (GetPersistenceName, Format, both GetTableNames), added godoc to the constructors/helpers on this path, and replaced the remaining utils.MustGet calls in sqlite tests/benchmarks with testify require or plain error propagation.

Breaking change

(*TableNameCreator).MustGetTableName is removed from platform/view/services/storage/db. Call CreateTableName and handle the error instead.

Fixes #1843

Test plan

  • make checks
  • make unit-tests

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Hey @mbrandenburger 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

✅ DCO Sign-off -- All commits have valid sign-offs. Nice work!


❌ GPG Signature -- Heads up! The following commits don't have a verified GPG signature:

  • 219afaa refactor!: propagate errors instead of panicking

You'll need to sign your commits with GPG (e.g. git commit -S). See the Signing Guide for a step-by-step walkthrough.


✅ Merge Conflicts -- No merge conflicts detected. Smooth sailing!


✅ Issue Link -- Linked to #1843 (assigned to you).


⏳ All checks must pass before this PR can be reviewed. You've got this!

@github-actions github-actions Bot added the status: needs review The pull request is ready for maintainer review label Sep 15, 2026
@mbrandenburger mbrandenburger added this to the 26Q3 milestone Sep 15, 2026
@mergify

mergify Bot commented Sep 15, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@mbrandenburger
mbrandenburger enabled auto-merge (squash) September 15, 2026 21:20
utils.Must/utils.MustGet turn an error into a panic. Four call sites on the
node-startup / store-construction path panicked despite every enclosing
function already returning error and already propagating sibling errors
normally: newKVS, GetPersistenceName, and the two GetTableNames functions.
They now return the error instead of crashing the process.

Also fixes escapeForTableName's bare panic on the same call path: Fabric
channel names legally contain digits, but escapeForTableName validated
against ^[a-zA-Z_]+$, so a channel named e.g. mychannel1 panicked at vault
store construction instead of surfacing the existing wrapped error at
channelprovider.go.

Wrap errors.Wrapf around the entry points that would otherwise lose context
on propagation (GetPersistenceName, Format, both GetTableNames), add godoc
to the constructors and helpers on this call path, and replace the
remaining utils.MustGet calls in sqlite tests and benchmarks with testify
require / plain error propagation.

BREAKING CHANGE: (*TableNameCreator).MustGetTableName is removed from
platform/view/services/storage/db; call CreateTableName and handle the
error instead. Table-name and persistence-name construction on the store
startup path (GetPersistenceName, GetTableNames, and escapeForTableName's
callers) no longer panics on invalid config or channel names; callers that
relied on that fail-fast crash now receive a normal error return.

Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@mbrandenburger
mbrandenburger force-pushed the nulls-must-error-handling branch from 275a11c to 219afaa Compare September 15, 2026 21:21
@mbrandenburger
mbrandenburger merged commit e127583 into hyperledger-labs:main Sep 15, 2026
13 of 14 checks passed
@mbrandenburger
mbrandenburger deleted the nulls-must-error-handling branch September 15, 2026 21:21
@github-actions github-actions Bot added status: needs revision The pull request requires changes from the author before it can be reviewed or merged and removed status: needs review The pull request is ready for maintainer review labels Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs revision The pull request requires changes from the author before it can be reviewed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid panicking if we can deal with an error

2 participants