INNER CODE UNIT · Python
format_body_markdown
Far-Se/tabame · plugins/api-client/main.py:205
def format_body_markdown(result):
body = result.get("body", "")
if not body:
return "_Empty response body_"
headers = result.get("headers") or {}
ctype = headers.get("Content-Type", "") or headers.get("content-type", "")
if "json" in ctype.lower():
try:
pretty = json.dumps(json.loads(body), indent=2, ensure_ascii=False)
return f"```json\n{pretty[:150000]}\n```"
except Exception:
pass
return f"```\n{body[:150000]}\n```"
def is_risky(method):
"""Heuristic: mutating verb + an active environment whose name suggests production."""
ln = (STATE.get("activeEnv") or "").lower()