Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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"
}
},
"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
6 changes: 4 additions & 2 deletions testdriver/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,11 @@ 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',
error_result = {'label': input['label'],
'input_data': input_line,
'error': self.run_error_message
'error': self.run_error_message,
'error_detail': 'severe error from subprocess ' +
result.returncode,
}
Comment on lines 518 to 523

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
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:
Expand Down
Loading