Skip to content

fix: try recovery from truncated xml string - #574

Open
GdoongMathew wants to merge 1 commit into
AsyncFuncAI:mainfrom
GdoongMathew:fix/truncated_xml
Open

fix: try recovery from truncated xml string#574
GdoongMathew wants to merge 1 commit into
AsyncFuncAI:mainfrom
GdoongMathew:fix/truncated_xml

Conversation

@GdoongMathew

Copy link
Copy Markdown
Collaborator

Summary

Try to recovery from truncated xml string, instead of raising exception and return nothing. (AI generated)

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds best-effort recovery for truncated or malformed wiki-structure XML rather than discarding the entire response.

  • Recovers complete pages, sections, and wiki metadata through regex fallbacks when strict XML parsing fails.
  • Adds tests covering truncation during a page and the absence of an opening wiki tag.

Confidence Score: 4/5

The 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

Important Files Changed

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

Comment on lines +227 to +228
title = _first_group(r"<title>([\s\S]*?)</title>", xml_text)
description = _first_group(r"<description>([\s\S]*?)</description>", xml_text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Regex fallback preserves XML entities

When strict parsing fails and a recovered title or description contains an XML entity such as &amp; or &lt;, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant