fix: improve content decoding in AppDslService (#12304)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN- 2025-01-02 16:54:46 +08:00 committed by GitHub
parent 0e6317678f
commit 375aa38f5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -104,7 +104,7 @@ class AppDslService:
raise ValueError(f"Invalid import_mode: {import_mode}") raise ValueError(f"Invalid import_mode: {import_mode}")
# Get YAML content # Get YAML content
content: bytes | str = b"" content: str = ""
if mode == ImportMode.YAML_URL: if mode == ImportMode.YAML_URL:
if not yaml_url: if not yaml_url:
return Import( return Import(
@ -124,7 +124,7 @@ class AppDslService:
yaml_url = yaml_url.replace("/blob/", "/") yaml_url = yaml_url.replace("/blob/", "/")
response = ssrf_proxy.get(yaml_url.strip(), follow_redirects=True, timeout=(10, 10)) response = ssrf_proxy.get(yaml_url.strip(), follow_redirects=True, timeout=(10, 10))
response.raise_for_status() response.raise_for_status()
content = response.content content = response.content.decode()
if len(content) > max_size: if len(content) > max_size:
return Import( return Import(