Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion executors/node/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ rl.on('line', function(line) {
if (test_type == "segmenter") {
outputLine = segmenter.testSegmenter(parsedJson);
} else {
outputLine = {'error': 'unknown test type',
// UNSUPPORTED TEST TYPE!
outputLine = {'label': 'UNKNOWN',
'error': 'unknown test type',
'error_detail': 'Requested unsupported test type',
'test_type': test_type,
'unsupported_test': test_type};
}
Expand Down
6 changes: 5 additions & 1 deletion schema/collation/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@
"warning": {
"description": "Present when data has a problem",
"type": "string"
}
},
"hash_id": {
"description": "Has value of the JSON string omtting label value",
"type": "integer"
}
Comment on lines +115 to +118
Copy link
Copy Markdown
Member

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_id used anywhere in this PR outside the schema. Why do you need it?

},
"required": [
"label",
Expand Down
4 changes: 4 additions & 0 deletions schema/lang_names/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"locale_label": {
"description": "locale tag of the language being described ",
"type": "string"
},
"hash_id": {
"description": "Has value of the JSON string omtting label value",
"type": "integer"
}
},
"additionalProperties": false
Expand Down
4 changes: 4 additions & 0 deletions schema/likely_subtags/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
"option": {
"description": "Type of processing requested",
"enum": ["maximize", "minimize", "minimizeFavorScript", "minimizeFavorRegion"]
},
"hash_id": {
"description": "Has value of the JSON string omtting label value",
"type": "integer"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions schema/number_format/test_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@
"default": "auto"
}
}
},
"hash_id": {
"description": "Has value of the JSON string omtting label value",
"type": "integer"
}
},
"required": [
Expand Down
31 changes: 19 additions & 12 deletions testdriver/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This block introduces two critical issues that will cause a crash:

  1. NameError: The variable input is used to get a label (input['label']), but it is not defined within this else block's scope. It is only defined in the except block below.
  2. TypeError: result.returncode is an integer. Concatenating it with a string using + will raise a TypeError. It must be converted to a string first, for example, by using str(result.returncode).

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),
                                }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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
Loading