Skip to content
Merged
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
2 changes: 1 addition & 1 deletion app/commands/submission/analysis/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def tags_data
return {} if ops_errored?

tags_json = tooling_job.execution_output['tags.json']
return {} if tags_json.blank?
return {} if tags_json&.scrub.blank?

res = JSON.parse(tags_json)
res.is_a?(Hash) ? res.symbolize_keys : {}
Expand Down
2 changes: 1 addition & 1 deletion app/commands/submission/representation/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def metadata
return {} if ops_errored?

representation_json = tooling_job.execution_output['representation.json']
return {} if representation_json.blank?
return {} if representation_json&.scrub.blank?

res = JSON.parse(representation_json)
res.is_a?(Hash) ? res.symbolize_keys : {}
Expand Down
2 changes: 1 addition & 1 deletion app/commands/submission/test_run/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def results
return {} if tooling_job.execution_output.nil?

results_json = tooling_job.execution_output['results.json']
return {} if results_json.blank?
return {} if results_json&.scrub.blank?

res = JSON.parse(results_json, allow_invalid_unicode: true)
res.is_a?(Hash) ? res.symbolize_keys : {}
Expand Down
17 changes: 17 additions & 0 deletions test/commands/submission/test_run/process_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ class Submission::TestRun::ProcessTest < ActiveSupport::TestCase
assert submission.reload.tests_exceptioned?
end

test "handle invalid UTF-8 in results.json without raising" do
submission = create :submission
job = create_test_runner_job!(
submission,
execution_status: 200,
results: { 'status' => 'pass', 'tests' => [] }
)

invalid_bytes = "\xFF\xFE".dup.force_encoding('UTF-8')
job.stubs(:execution_output).returns({ 'results.json' => invalid_bytes })

# This should not raise ArgumentError: invalid byte sequence in UTF-8
Submission::TestRun::Process.(job)

assert submission.reload.tests_exceptioned?
end

test "handle tests pass" do
submission = create :submission
results = { 'status' => 'pass', 'message' => "", 'tests' => [] }
Expand Down
Loading