mirror of
				https://github.com/langgenius/dify.git
				synced 2025-11-03 20:33:00 +00:00 
			
		
		
		
	use repair_json fix json parse error of HTTPRequestNode (#21909)
Co-authored-by: lizb <lizb@sugon.com>
This commit is contained in:
		
							parent
							
								
									317d287458
								
							
						
					
					
						commit
						c9c49200e0
					
				@ -8,6 +8,7 @@ from typing import Any, Literal
 | 
			
		||||
from urllib.parse import urlencode, urlparse
 | 
			
		||||
 | 
			
		||||
import httpx
 | 
			
		||||
from json_repair import repair_json
 | 
			
		||||
 | 
			
		||||
from configs import dify_config
 | 
			
		||||
from core.file import file_manager
 | 
			
		||||
@ -178,7 +179,8 @@ class Executor:
 | 
			
		||||
                        raise RequestBodyError("json body type should have exactly one item")
 | 
			
		||||
                    json_string = self.variable_pool.convert_template(data[0].value).text
 | 
			
		||||
                    try:
 | 
			
		||||
                        json_object = json.loads(json_string, strict=False)
 | 
			
		||||
                        repaired = repair_json(json_string)
 | 
			
		||||
                        json_object = json.loads(repaired, strict=False)
 | 
			
		||||
                    except json.JSONDecodeError as e:
 | 
			
		||||
                        raise RequestBodyError(f"Failed to parse JSON: {json_string}") from e
 | 
			
		||||
                    self.json = json_object
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user