Open mieslep opened 3 hours ago
The issue you're experiencing, where data types in the APIRequest
response are being converted to strings in the component output, is likely due to the serialization process in the make_request
method. This method uses json.dumps(data)
to serialize the request body into a JSON-formatted string, which converts all data types into their string representations [1].
To address this, you might need to review how the data is being processed after the response is received. The make_request
method attempts to parse the response content as JSON and stores it in the result
field of the Data
object. If the JSON parsing fails, it falls back to storing the response text [1].
Additionally, ensure that any further processing or rendering of the data does not inadvertently convert the data types to strings. You might want to check if there are any specific methods or functions in the codebase that explicitly convert non-string data types to strings, such as data_to_string
, document_to_string
, or dict_values_to_string
[2].
To continue talking to Dosu, mention @dosu.
I suspect the problem is in how the Data object is deserializing the result:
response = await client.request(method, url, headers=headers, json=data, timeout=timeout)
try:
result = response.json()
except Exception: # noqa: BLE001
result = response.text
return Data(
data={
"source": url,
"headers": headers,
"status_code": response.status_code,
"result": result,
},
)
but I have not been able to get an environment working to be able to further isolate this.
Bug Description
Server requests come back and the .json() values have correct types (numbers, booleans, strings), but in the component output all of the values are converted to string.
Reproduction
This flow uses postman-echo.com to send a request body which is echoed back, and includes some
logger.debug
statements:API RequestWithDebug.json
And we can see from the log outputs, the numbers and booleans are not wrapped in ":
However if you inspect the output record HTML, the response value has converted these to strings:
And in the new dict viewer the values are string.
Expected behavior
Data types should be as they were in the JSON response.
Who can help?
No response
Operating System
Windows
Langflow Version
v1.0.19.dev24
Python Version
3.12
Screenshot
No response
Flow File
API Reponse Debug.json