Skip to content

Commit da88042

Browse files
committed
SK-1909 Fix inconsistencies and issues in Python SDK v2
1 parent a9a44d8 commit da88042

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

skyflow/error/_skyflow_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self,
88
request_id = None,
99
grpc_code = None,
1010
http_status = None,
11-
details = None):
11+
details = []):
1212
self.message = message
1313
self.http_code = http_code
1414
self.grpc_code = grpc_code

skyflow/utils/_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ def parse_invoke_connection_response(api_response: requests.Response):
359359

360360
if error_from_client is not None:
361361
if details is None: details = []
362-
details.append({'error_from_client': error_from_client})
362+
error_from_client_bool = error_from_client.lower() == 'true'
363+
details.append({'error_from_client': error_from_client_bool})
363364

364365
raise SkyflowError(message, status_code, request_id, grpc_code, http_status, details)
365366
except json.JSONDecodeError:
@@ -397,7 +398,7 @@ def handle_json_error(err, data, request_id, logger):
397398
status_code = description.get('error', {}).get('http_code', 500) # Default to 500 if not found
398399
http_status = description.get('error', {}).get('http_status')
399400
grpc_code = description.get('error', {}).get('grpc_code')
400-
details = description.get('error', {}).get('details')
401+
details = description.get('error', {}).get('details', [])
401402

402403
description_message = description.get('error', {}).get('message', "An unknown error occurred.")
403404
log_and_reject_error(description_message, status_code, request_id, http_status, grpc_code, details, logger = logger)

skyflow/vault/controller/_vault.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def __build_batch_field_records(self, values, tokens, table_name, return_tokens,
4343
upsert=upsert,
4444
tokens=token
4545
)
46-
if token is not None:
47-
batch_record.tokens = token
4846
batch_record_list.append(batch_record)
4947
return batch_record_list
5048

tests/vault/controller/test__connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ def test_parse_invoke_connection_response_error_from_client(self):
120120

121121
exception = context.exception
122122

123-
self.assertTrue(any(detail.get('error_from_client') == 'true' for detail in exception.details))
123+
self.assertTrue(any(detail.get('error_from_client') == True for detail in exception.details))
124124
self.assertEqual(exception.request_id, '12345')
125125

0 commit comments

Comments
 (0)