-
Notifications
You must be signed in to change notification settings - Fork 947
fix(builder): improve error message extraction in task results #10173
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
base: master
Are you sure you want to change the base?
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,7 +81,34 @@ export class TaskResultsList { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private aggregateTaskErrorsToOneString(componentResult: ComponentResult) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const rawErrors = componentResult.errors || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const errors = rawErrors.map((e) => (typeof e === 'string' ? e : e.toString())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const errors = rawErrors.map((e) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof e === 'string') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (e instanceof Error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return e.message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Handle error objects with message and/or stack properties | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (e && typeof e === 'object') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const errorObj = e as Record<string, any>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hasMessage = 'message' in e && typeof errorObj.message === 'string'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hasStack = 'stack' in e && typeof errorObj.stack === 'string'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (hasMessage && hasStack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return `${errorObj.message}\n${errorObj.stack}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (hasMessage) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return errorObj.message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (hasStack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return errorObj.stack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Try toString as final fallback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof (e as any)?.toString === 'function') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return (e as any).toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return `unknown error format: ${JSON.stringify(e)}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+89
to
+110
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return e.message; | |
| } | |
| // Handle error objects with message and/or stack properties | |
| if (e && typeof e === 'object') { | |
| const errorObj = e as Record<string, any>; | |
| const hasMessage = 'message' in e && typeof errorObj.message === 'string'; | |
| const hasStack = 'stack' in e && typeof errorObj.stack === 'string'; | |
| if (hasMessage && hasStack) { | |
| return `${errorObj.message}\n${errorObj.stack}`; | |
| } | |
| if (hasMessage) { | |
| return errorObj.message; | |
| } | |
| if (hasStack) { | |
| return errorObj.stack; | |
| } | |
| } | |
| // Try toString as final fallback | |
| if (typeof (e as any)?.toString === 'function') { | |
| return (e as any).toString(); | |
| } | |
| return `unknown error format: ${JSON.stringify(e)}`; | |
| // Prefer including stack when available for better diagnostics | |
| if (e.stack) { | |
| return `${e.message}\n${e.stack}`; | |
| } | |
| return e.message; | |
| } | |
| // Fallback for unexpected values; should not occur if types are respected | |
| return String(e); |
Copilot
AI
Feb 1, 2026
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.
JSON.stringify(e) can throw (e.g., circular references) which would cause error formatting itself to crash and potentially mask the original failure. Use a safe stringification (try/catch with a fallback) or a non-throwing formatter like util.inspect for the fallback message.
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.
For
Errorinstances, this returns onlye.message, so the stack trace is dropped (and the output also loses the error name). This doesn’t match the PR goal of extractingmessage+stackand makes debugging harder. Consider usinge.stackwhen available (ore.name+e.messageplus stack) instead of message-only.