Skip to content
Open
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions volcenginesdkcore/interceptor/interceptors/response.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import json
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

PEP8: add a blank line after the import and before the class definition (top-level class definitions should be separated by two blank lines).

Suggested change
import json
import json

Copilot uses AI. Check for mistakes.
class Response:
def __init__(self, http_response):
self.http_response = http_response
self.result = None
self.metadata = None
self.__post_init__()

def __post_init__(self):
data = json.loads(self.http_response.data)
self.result = data.get("Result")
self.metadata = data.get("ResponseMetadata")
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

ResponseMetadata error handling is skipped here: if the JSON contains a ResponseMetadata.Error block, Response will still populate result/metadata and no ApiException is raised. To keep behavior consistent with DeserializedResponseInterceptor.deserialize (which raises on Error / missing ResponseMetadata), consider checking ResponseMetadata.Error and raising the same ApiException (or deferring JSON parsing to that interceptor).

Suggested change
self.result = data.get("Result")
self.metadata = data.get("ResponseMetadata")
metadata = data.get("ResponseMetadata")
if metadata is None:
raise ValueError("Missing ResponseMetadata in HTTP response.")
error = metadata.get("Error") if isinstance(metadata, dict) else None
if error:
raise ValueError(f"API returned error in ResponseMetadata: {error}")
self.metadata = metadata
self.result = data.get("Result")

Copilot uses AI. Check for mistakes.
Loading