-
Notifications
You must be signed in to change notification settings - Fork 6
fix(deploy): handle SAS9 execution error gracefully #1065
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: main
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import path from 'path' | ||
| import os from 'os' | ||
| import SASjs from '@sasjs/adapter/node' | ||
| import SASjs, { JobExecutionError } from '@sasjs/adapter/node' | ||
| import { getAuthConfig, getStreamConfig } from '../../utils/config' | ||
| import { displaySasjsRunnerError, executeShellScript } from '../../utils/utils' | ||
| import { | ||
|
|
@@ -252,16 +252,24 @@ async function deployToSas9( | |
| }) | ||
| const executionResult = await sasjs | ||
| .executeScriptSAS9(linesToExecute, username, password) | ||
| .catch((err) => { | ||
| process.logger?.log(formatErrorString(err)) | ||
| .catch(async (err) => { | ||
| if (err && err.errorCode === 404) { | ||
|
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. 🟡 Regression: the previous code logged |
||
| displaySasjsRunnerError(username) | ||
| } else if (err instanceof JobExecutionError) { | ||
|
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. 💡 This branch is only reachable for a |
||
| process.logger?.error('Deployment completed with errors.') | ||
| const errorLogPath = path.join( | ||
| logFilePath || process.cwd(), | ||
| `${path.basename(deployScript).replace('.sas', '')}.log` | ||
| ) | ||
| await createFile(errorLogPath, err.result) | ||
| process.logger?.info(`Error log is available at ${errorLogPath}`) | ||
| throw new Error() | ||
|
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. 🟡 |
||
| } else { | ||
| process.logger?.error(formatErrorString(err)) | ||
| } | ||
| }) | ||
|
|
||
| if (!executionResult) { | ||
| process.logger?.error('Error getting execution log') | ||
| } else if (logFilePath) { | ||
| if (executionResult && logFilePath) { | ||
| await createFile( | ||
| path.join( | ||
| logFilePath, | ||
|
|
||
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.
🔴 Branch ordering blocks the new feature. The adapter's
parseErrorproduces aJobExecutionErrorwitherrorCode: 404for both "stored process not found" and "Stored Process Error / This request completed with errors" (the latter carries the SAS log inresult). Since thiserrorCode === 404check comes first, everyJobExecutionErrorfrom the SAS9 path falls into this branch and callsdisplaySasjsRunnerError— theelse if (err instanceof JobExecutionError)branch below is never reached for SAS9. Recommend checkingerr instanceof JobExecutionErrorfirst, then distinguishing runner-missing (resultempty) from stored-process-error (resulthas the log).