apache/hadoop · error · InvalidXmlException

More than one value found for {}

Error message

More than one value found for {}

What it means

Stanza.getValueOrNull accepts an entry only when its list has exactly one stanza: it checks subtrees.containsKey(name), fetches the LinkedList, and throws InvalidXmlException("More than one value found for " + name) when l.size() != 1. In well-formed fsimage XML each scalar field appears once per parent, so a size other than 1 means malformed input (0 can also land here only if the key was added with an empty list; the common case is 2+).

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/util/XMLUtils.java:332

        throw new InvalidXmlException("no entry found for " + name);
      }
      return ret;
    }

    /** 
     * Pull a string entry from a stanza, or null.
     *
     * @param name        entry to look for
     * 
     * @return            the entry, or null if it was not found.
     */
    public String getValueOrNull(String name) throws InvalidXmlException {
      if (!subtrees.containsKey(name)) {
        return null;
      }
      LinkedList <Stanza> l = subtrees.get(name);
      if (l.size() != 1) {
        throw new InvalidXmlException("More than one value found for " + name);
      }
      return l.get(0).getValue();
    }
    
    /** 
     * Add an entry to a stanza.
     *
     * @param name        name of the entry to add
     * @param child       the entry to add
     */
    public void addChild(String name, Stanza child) {
      LinkedList<Stanza> l;
      if (subtrees.containsKey(name)) {
        l = subtrees.get(name);
      } else {
        l = new LinkedList<Stanza>();
        subtrees.put(name, l);
      }

View on GitHub (pinned to 2add963021)

Solutions

  1. Remove the duplicate element so exactly one remains
  2. If multiple values are legitimate for your data model, read them with getChildren(name) instead of getValue(name)
  3. Validate uniqueness (count occurrences per parent element) before parsing

Example fix

<!-- before: duplicate element inside one parent -->
<INODE><NAME>a</NAME><NAME>b</NAME></INODE>

<!-- after -->
<INODE><NAME>a</NAME></INODE>
Defensive patterns

Strategy: try-catch

Try / catch

try {
  String v = stanza.getValue(name);
} catch (InvalidXmlException e) {
  // size != 1: duplicated element in the XML stanza
}

Prevention

When it happens

Trigger: The XML contains the same element twice inside one parent (e.g. two <NAME> children under one <INODE>), so the stanza's list for that name has size 2; any getValue/getValueOrNull call on it throws.

Common situations: Merging or hand-editing OIV XML that duplicated a field; buggy XML generators emitting repeated elements; processing concatenated or diff-merged dumps.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/6e47d3c6d76c9f0a. Report an issue: GitHub.