-
Notifications
You must be signed in to change notification settings - Fork 22
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
#3216 JQ fromdate error gets cut off in page editor #3336
Conversation
src/errors.ts
Outdated
@@ -250,6 +250,16 @@ export function isContextError(error: unknown): error is ContextError { | |||
); | |||
} | |||
|
|||
// The serializeError preserves custom properties that effectively means the "cause" is skipped by the serializer | |||
export function serializePixiebrixError(error: Error): ErrorObject { |
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.
If we keep this function it needs to be renamed.
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.
Could you add a link to the issue here? sindresorhus/serialize-error#74
Codecov Report
@@ Coverage Diff @@
## main #3336 +/- ##
==========================================
+ Coverage 36.77% 36.89% +0.11%
==========================================
Files 751 751
Lines 21509 21526 +17
Branches 4590 4595 +5
==========================================
+ Hits 7911 7941 +30
+ Misses 12682 12669 -13
Partials 916 916
Continue to review full report at Codecov.
|
src/blocks/transformers/jq.ts
Outdated
message = | ||
"Unexpected end of jq filter, are you missing a parentheses, brace, and/or quote mark?"; | ||
} else { | ||
const jqMessageFromStack = jqStacktraceRegexp.exec(error.stack)?.groups |
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.
You can write it this way to avoid the nested condition. Prettier will likely improve the wrapping further
const jqMessageFromStack = jqStacktraceRegexp.exec(error.stack)?.groups | |
message = jqStacktraceRegexp.exec(error.stack)?.groups?.message.trim() | |
?? "Invalid jq filter, see error log for details" |
src/background/logging.ts
Outdated
@@ -333,7 +334,7 @@ export async function recordError( | |||
data, | |||
|
|||
// Ensure it's serialized | |||
error: serializeError(maybeSerializedError), | |||
error: serializePixiebrixError(maybeSerializedError as Error), |
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.
serializeError
must accept unknown
; as Error
is unsafely asserting that unknown
is an Error
without actually checking for it.
src/errors.test.ts
Outdated
@@ -291,3 +293,22 @@ describe("selectError", () => { | |||
); | |||
}); | |||
}); | |||
|
|||
describe("serializatin", () => { |
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.
describe("serializatin", () => { | |
describe("serialization", () => { |
[] | ||
); | ||
const contextError = new ContextError("text context error", { | ||
cause: inputValidationError, |
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.
Indeed this was a bug:
This is a temporary issue so I wouldn't spend too much time on it 👍
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 added some tests 📈 and added some comments to clarify the context around that helper function a bit more. I also made it so the other errors thrown are BusinessErrors (indicating the brick is misconfigured)
Fixes #3216