-
-
Notifications
You must be signed in to change notification settings - Fork 279
fix(account-tree-controller/backup-and-sync): do not send extra metadata properties #8300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { toErrorMessage } from './errors'; | ||
|
|
||
| describe('toErrorMessage', () => { | ||
| it('returns the message property for Error instances', () => { | ||
| expect(toErrorMessage(new Error('something went wrong'))).toBe( | ||
| 'something went wrong', | ||
| ); | ||
| }); | ||
|
|
||
| it('returns String() for non-Error values', () => { | ||
| expect(toErrorMessage('raw string error')).toBe('raw string error'); | ||
| expect(toErrorMessage(42)).toBe('42'); | ||
| expect(toErrorMessage(null)).toBe('null'); | ||
| expect(toErrorMessage(undefined)).toBe('undefined'); | ||
| expect(toErrorMessage({ code: 500 })).toBe('[object Object]'); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /** | ||
| * Extracts a string message from an unknown error value. | ||
| * | ||
| * @param error - The caught error value. | ||
| * @returns The error message string. | ||
| */ | ||
| export function toErrorMessage(error: unknown): string { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this mostly because it was hard to get coverage when re-using this pattern in the fix I made in Otherwise I would have to mock Delegating this coverage to this helper makes the code easier and keep the test focused on the new behavior fix (IMO)!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I used a similar pattern in the service too, |
||
| return error instanceof Error ? error.message : String(error); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './controller'; | ||
| export { toErrorMessage } from './errors'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale behind keeping
groupIndexhere? Does this help the account tree to be built properly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just kept the semantic of the function (it couldn't fail/throw before we started introducing the
maskcall), so in case an error happens, I don't want to make it throw either.IDK if we can do better than that actually 🤔 the way I see this is that, we need at least the
groupIndex, everything else (for now) is optional, so worst case scenario, we omit all metadata and go with thegroupIndex.Would you prefer to throw instead, so this could bubble up and potentially make B&S fail entirely (I haven't analyzed the call sites TBH 🙊)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! No, I actually didn't think that far ahead, I just wanted to understand your intent. I think your logic is sound :)