seanmuth commented on issue #69980:
URL: https://github.com/apache/airflow/issues/69980#issuecomment-4996835068
Here's a cleaner db-agnostic repair script to run in python, claude
generated and not tested by me, just FYI, but applies the same fix over the
data that the (fixed) migration would do:
```python
import json
from sqlalchemy import create_engine, text
def repair(node):
if isinstance(node, dict):
if "__type" in node and "__var" in node:
if node["__type"] == "dict" and isinstance(node["__var"], dict):
return {"__type": "dict", "__var": {k: repair(v) for k, v in
node["__var"].items()}}
return node
return {"__type": "dict", "__var": {k: repair(v) for k, v in
node.items()}}
if isinstance(node, list):
return [repair(v) for v in node]
return node
eng = create_engine("mysql://…") # or postgresql://…
with eng.begin() as c:
rows = c.execute(text("SELECT id, data FROM callback")).mappings().all()
for r in rows:
data = r["data"] if isinstance(r["data"], (dict, list)) else
json.loads(r["data"])
fixed = repair(data)
if fixed != data:
c.execute(text("UPDATE callback SET data = :d WHERE id = :i"),
{"d": json.dumps(fixed), "i": r["id"]})
```
--
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]