feat: Error sanitization for user-facing services #413
Open
gokutheengineer wants to merge 11 commits intobsv-blockchain:mainfrom
Open
feat: Error sanitization for user-facing services #413gokutheengineer wants to merge 11 commits intobsv-blockchain:mainfrom
gokutheengineer wants to merge 11 commits intobsv-blockchain:mainfrom
Conversation
Contributor
|
🤖 Claude Code Review Status: Complete Current Review:
History:
|
9b0916e to
0f870c1
Compare
0e64ada to
05297aa
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Error Sanitization for User-Facing Services
Context
We observed verbose error chains leaking internal details (e.g., Aerospike, underlying storage errors, and deep wrapped chains) into user-facing surfaces (propagation, asset server, p2p). This is useful for debugging but not appropriate for external clients.
Goal
Return succinct, safe error messages to users while preserving full error detail in logs and internal chains.
Summary of Changes
Centralized sanitization helpers
errorsto generate concise, public-safe messages and sanitized errors for gRPC/HTTP.Propagation service sanitization
TErrorper item.Asset server sanitization
P2P API sanitization
Detailed Changes
New error helpers (
errors/errors.go)UserMessage(err)Returns a concise message like
TX_INVALID (31): tx invalid(no wrapped chain, no data).PublicError(err)Creates a sanitized
*errors.Errorwith onlycode + message.WrapGRPCPublic(err)Produces a gRPC status with only the sanitized code/message.
WrapPublic(err)Converts to sanitized
*errors.TError(used in batch responses).Propagation (
services/propagation/Server.go)/txand/txsHTTP error responses now useerrors.UserMessage(err)(removes internal storage/db details and long chains).
ProcessTransactionreturnsWrapGRPCPublic(err)to keep responses minimal.ProcessTransactionBatchusesWrapPublic(err)per item to strip details.Asset server (
services/asset/httpimpl/sendError.go)errors.UserMessage(err)instead oferr.Error().P2P (
services/p2p/Server.go)GetPeerswhen P2P client not initializedBanPeer,UnbanPeererrorsRecordBytesDownloadeddecode errorsExample Before/After
Before (too verbose):
After (sanitized):
or
Files Touched
errors/errors.goservices/propagation/Server.goservices/asset/httpimpl/sendError.goservices/p2p/Server.goRisks / Considerations
Follow-ups (Optional)
Note
There is an additional change in
services/propagation/Server.goto ignoreErrBlobAlreadyExistswhen storing transactions. This appears separate from sanitization and is not part of the error-sanitization scope.