Skip to content

rfl::xml: distinguish empty vs declaration-only XML and add ErrorKind tagging to xml::read / xml::Reader #112

Done

Description

@clockblocker

Bug

  1. rfl::xml::read(std::string_view) conflates empty/whitespace-only input ("", " \n") with XML-declaration-only ("<?xml version=\"1.0\"?>") or comment-only ("<!-- ... -->") documents because pugixml's doc.load_buffer(...) returns pugi::status_no_document_element identically for all of them. As a result, include/rfl/xml/read.hpp:55 ("XML document has no root element.") is unreachable from read(std::string_view) and consumers must pre-scan whitespace manually.
  2. include/rfl/xml/read.hpp and include/rfl/xml/Reader.hpp currently emit zero rfl::ErrorKind tags on showcase/all-lanes (every XML parse/type/value error falls back to ErrorKind::other), lagging behind rfl::json and rfl::env.

Evidence & Root Cause

Acceptance Criteria

  • In rfl::xml::read(std::string_view): distinguish empty/whitespace-only input ("XML document is empty.", ErrorKind::syntax_error) from non-empty declaration/comment-only input with status_no_document_element ("XML document has no root element.", ErrorKind::syntax_error) and malformed XML syntax (ErrorKind::syntax_error).
  • Tag rfl::xml::Reader errors to match rfl::json::Reader & rfl::env::Reader:
    • get_field_from_array / get_field_from_object → ErrorKind::missing_field
    • to_basic_type lexical cast failures → ErrorKind::invalid_value
    • cast_as_node on attribute → ErrorKind::invalid_type
  • Add regression tests verifying distinct messages and ErrorKind values for empty input, declaration-only input, malformed XML, missing fields, invalid scalar values, and invalid node/attribute types.

Activity

  1. added
    bug
    ready-for-agent
    on Nov 27, 2026
  2. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Resolved on showcase/all-lanes via Batch 1 merge 4861aafd (commits d4700190, d3673b24). Verified with 962/962 CTest passing under AppleClang 17 -Wall -Werror + REFLECTCPP_STRICT_WARNINGS=ON (non-SYSTEM -I for internal tests, -isystem for downstream consumers) and dual Judge approval (Gemini 4 Neon High: APPROVE WITH NITS, all addressed; Claude Opus 5.5 High re-check: APPROVE).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions