fix: try recovery from truncated xml string - #574
Conversation
Greptile SummaryThe PR adds best-effort recovery for truncated or malformed wiki-structure XML rather than discarding the entire response.
Confidence Score: 4/5The recovery behavior should be corrected before merging because malformed responses can produce visibly encoded wiki metadata. The fallback now exposes raw XML entity syntax in recovered title, description, and section-title fields, while the normal parser returns decoded text. Files Needing Attention: api/services/wiki/structure.py
|
| Filename | Overview |
|---|---|
| api/services/wiki/structure.py | Adds truncated-response recovery, but regex-extracted textual fields retain XML entity encoding unlike the strict parser. |
| tests/backend/services/test_wiki_structure.py | Adds focused coverage for recovering complete records from a response truncated during its final page. |
Reviews (1): Last reviewed commit: "fix: try recovery from truncated xml str..." | Re-trigger Greptile
| title = _first_group(r"<title>([\s\S]*?)</title>", xml_text) | ||
| description = _first_group(r"<description>([\s\S]*?)</description>", xml_text) |
There was a problem hiding this comment.
Regex fallback preserves XML entities
When strict parsing fails and a recovered title or description contains an XML entity such as & or <, the regex fallback returns the encoded source text instead of the decoded value produced by ElementTree, causing generated wiki metadata to display or serialize literal entity syntax.
Summary
Try to recovery from truncated xml string, instead of raising exception and return nothing. (AI generated)