jscheffl commented on code in PR #40640:
URL: https://github.com/apache/airflow/pull/40640#discussion_r1672830793


##########
airflow/www/static/js/dag/details/taskInstance/Xcom/XcomEntry.tsx:
##########
@@ -66,6 +67,10 @@ const XcomEntry = ({
         No value found for XCom key
       </Alert>
     );
+  } else {
+    const xcomStr = xcom?.value as string;
+    const xcomStrR = xcomStr.replace(/'/g, '"');

Review Comment:
   @bbovenzi  Okay, I am also not happy about the `replace()` and it might be a 
bit hacky. Do you have an idea to make it "proper"?
   
   Problem is: The serialized dict is serialized in Python in the XCom. The API 
response with a string containing the serialized XCom from the Python 
serialization. We get this as a "bad string" in JavaScript.
   
   Best would be to change the API but I'd assume this will be treated as 
breaking change, getting a "real" object/JSon dict.
   
   Currently the API generates something like:
   `{'key': 'value'}`
   
   whereas the JavaScript `JSON.parse()` expects:
   `{"key": "value"}`
   
   The regex is fixing the simple things... but how about if the XCom is Python 
was:
   `return {"key": "value", "quote": "\"", "stringify": "'test'", "complex": 
"\'\"\\"}`
   
   ...then the XCom string received is:
   `{'key': 'value', 'quote': '\"', 'stringify': \"'test'\", 'complex': 
'\\'\"\\\\'}`
   
   Do you know (could not find any with Google) proper way to convert Python 
dict/string to proper JavaScript JSON? All examples propose how to make it 
"right" in Python.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to