Skip to content

Commit

Permalink
Fix BYOB job results bytes typing issue (#1220)
Browse files Browse the repository at this point in the history
* try/except raw result truncation

* catch typeError

* revert try/except, use response.text

* update unit test
  • Loading branch information
kt474 authored Nov 16, 2023
1 parent dfc79aa commit 5b66120
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/runtime_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _download_external_result(self, response: Any) -> Any:
if "url" in result_url_json:
url = result_url_json["url"]
result_response = requests.get(url, timeout=10)
return result_response.content
return result_response.text
return response
except json.JSONDecodeError:
return response
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/byte-result-bug-7afb5abe813f5b1b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fixed an issue where canceled and failed jobs would return an invalid result that
resulted in a type error, preventing the actual error from being returned
to the user.
2 changes: 1 addition & 1 deletion test/unit/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def test_download_external_job_result(self, service):
job = run_program(service=service)
with mock_wait_for_final_state(service, job):
mock_response = MagicMock()
mock_response.content = "content-from-external-url"
mock_response.text = "content-from-external-url"
request_mock.get.return_value = mock_response
with mock_wait_for_final_state(service, job):
job.wait_for_final_state()
Expand Down

0 comments on commit 5b66120

Please sign in to comment.