-
-
Notifications
You must be signed in to change notification settings - Fork 13
Handle missing executor in NodeJS #528
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
c82fe0a
c702757
3dc28a5
bda88c6
ae3797a
4aee413
218d52a
9cf3a0e
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 |
|---|---|---|
|
|
@@ -500,9 +500,12 @@ def send_one_line(self, input_line): | |
| capture_output=True, | ||
| env=self.exec_env, | ||
| shell=True) | ||
| if not result.returncode: | ||
| if result.returncode == 0: | ||
| # Command worked! | ||
| return result.stdout | ||
| else: | ||
| input = json.loads(input_line.replace('#EXIT', '').strip()) | ||
| # non-zero return code indicates some kind of problem | ||
| logging.debug('$$$$$$$$$$$$$$$$ ---> return code: %s', result.returncode) | ||
| logging.debug(' ----> INPUT LINE= >%s<', input_line) | ||
| logging.debug(' ----> STDOUT= >%s<', result.stdout) | ||
|
|
@@ -512,19 +515,23 @@ def send_one_line(self, input_line): | |
| logging.error(' !!!!!! %s' % self.run_error_message) | ||
|
|
||
| # Handle problems with decoding errors and other unknowns. | ||
| error_result = {'label': 'UNKNOWN', | ||
| 'input_data': input_line, | ||
| 'error': self.run_error_message | ||
| error_result = {'label': input['label'], | ||
| 'input_data': input, | ||
| 'error': self.run_error_message, | ||
| 'error_detail': 'severe error from subprocess ' + | ||
| str(result.returncode) | ||
| } | ||
|
Comment on lines
+518
to
523
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 block introduces two critical issues that will cause a crash:
I've provided a suggestion that resolves both issues by safely parsing the input to retrieve the label and correctly handling the type conversion. label = 'UNKNOWN'
try:
input_json = json.loads(input_line.splitlines()[0])
label = input_json.get('label', 'UNKNOWN')
except (IndexError, json.JSONDecodeError):
pass # Fallback to 'UNKNOWN' if parsing fails
error_result = {'label': label,
'input_data': input_line,
'error': self.run_error_message,
'error_detail': 'severe error from subprocess ' +
str(result.returncode),
}
Member
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. please fix |
||
| return json.dumps(error_result) | ||
| except BaseException as err: | ||
| logging.error('Err = %s', err) | ||
| input = json.loads(input_line.replace('#EXIT', '').strip()) | ||
| error_result = {'label': input['label'], | ||
| 'input_data': input, | ||
| 'error': err | ||
| } | ||
| return json.dumps(error_result) | ||
|
|
||
| try: | ||
| input = json.loads(input_line.replace('#EXIT', '').strip()) | ||
| logging.error('Err = %s', err) | ||
| error_result = {'label': input['label'], | ||
| 'input_data': input, | ||
| 'error': err | ||
| } | ||
| return json.dumps(error_result) | ||
| except BaseException as error: | ||
| logging.error('testplan.py: Error = %s. input_line = <%s>', err, input_line) | ||
|
|
||
| return None | ||
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.
Question: I don't see
hash_idused anywhere in this PR outside the schema. Why do you need it?