Ensure error message stringified safely#692
Merged
yeasy merged 4 commits intohyperledger-cello:mainfrom Jun 23, 2025
Merged
Conversation
Previously, `api.common.response.err()` in api-engine was used in two contexts: 1. To pass plain error messages (strings). 2. To pass `Exception.args` from the API engine, which is a Python tuple. Since JavaScript’s template strings call `.toString()` on non‑string values, passing a tuple resulted in "[object Object]" in the UI. This change normalizes the error payload so that: - Strings pass through unchanged. - Arrays and objects are serialized via `JSON.stringify()`. - Other types are converted with `String()`. As a result, all error messages should display correctly in the frontend without "[object Object]" artifacts. Signed-off-by: dodo920306 <dodo920306@gmail.com>
ESLint no-else-return https://eslint.org/docs/latest/rules/no-else-return Signed-off-by: dodo920306 <dodo920306@gmail.com>
Users don't want/need to know what API causes the error. They should only be shown the message. Signed-off-by: dodo920306 <dodo920306@gmail.com>
YoungHypo
approved these changes
Jun 21, 2025
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.
Previously,
api.common.response.err()in api-engine was used in two contexts:Exception.argsfrom the API engine, which is a Python tuple.Since JavaScript’s template strings call
.toString()on non‑string values, passing a tuple resulted in[object Object]in the UI.This change normalizes the error payload so that:
JSON.stringify().String().As a result, all error messages should display correctly in the frontend without
[object Object]artifacts.