jenkinsci/jenkins · error · IOException

Failed to parse XML

Error message

Failed to parse XML

What it means

IOException wrapping a SAXException thrown while parsing a config.xml file to extract requested plugin dependencies. The XML is parsed with a secure SAXParser (disallowing DOCTYPE declarations and enabling secure processing). Any malformed XML, unexpected encoding, or XML structure violation triggers this.

Source

Thrown at core/src/main/java/hudson/PluginManager.java:2329

                        throw new SAXException("Malformed plugin attribute: " + plugin);
                    }
                    int at = plugin.indexOf('@');
                    String shortName = plugin.substring(0, at);
                    VersionNumber existing = requestedPlugins.get(shortName);
                    VersionNumber requested = new VersionNumber(plugin.substring(at + 1));
                    if (existing == null || existing.compareTo(requested) < 0) {
                        requestedPlugins.put(shortName, requested);
                    }
                }

                @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException,
                        SAXException {
                    return RestrictiveEntityResolver.INSTANCE.resolveEntity(publicId, systemId);
                }

            });
        } catch (SAXException x) {
            throw new IOException("Failed to parse XML", x);
        } catch (ParserConfigurationException e) {
            throw new AssertionError(e); // impossible since we don't tweak XMLParser
        }
        return requestedPlugins;
    }

    @Restricted(DoNotUse.class) // table.jelly
    public MetadataCache createCache() {
        return new MetadataCache();
    }

    /**
     * Disable a list of plugins using a strategy for their dependents plugins.
     * @param strategy the strategy regarding how the dependent plugins are processed
     * @param plugins the list of plugins
     * @return the list of results for every plugin and their dependent plugins.
     * @throws IOException see {@link PluginWrapper#disable()}
     */

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Validate the config.xml file with an XML validator (xmllint, an IDE) before loading.
  2. Restore config.xml from backup if corrupted.
  3. Check file encoding — must be valid UTF-8.
  4. Inspect the wrapped SAXException (e.getCause()) for line/column of the parse error.

Example fix

# before — config.xml has a syntax error (unclosed tag)
# <project> ... (missing </project>)

# fix
xmllint --noout config.xml  # validate
# correct the XML structure, then reload
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate XML well-formedness before passing to parseRequestedPlugins
try {
    DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(configXml);
} catch (Exception e) {
    throw new IllegalArgumentException("config.xml is not well-formed XML: " + e.getMessage(), e);
}

Try / catch

try {
    Map<String, VersionNumber> deps = pluginManager.parseRequestedPlugins(configXml);
} catch (IOException e) {
    Throwable cause = e.getCause();
    listener.error("Failed to parse config.xml: " + (cause != null ? cause.getMessage() : e.getMessage()));
    // recover from backup or skip plugin dependency resolution
}

Prevention

When it happens

Trigger: config.xml content that is not well-formed XML, contains invalid characters, has encoding issues, or triggers a SAX parse error during the dependency extraction pass.

Common situations: Corrupted or truncated config.xml file (e.g., from a disk-full write, interrupted save), manually edited XML with syntax errors, or a config.xml from an incompatible Jenkins version with unexpected structure.

Understand the failure class

Related errors


AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14). Data as JSON: /api/errors/c9693357fe49f829. Report an issue: GitHub.