usebruno/bruno · error · TypeError
minifyXml expects a string
Error message
minifyXml expects a string
What it means
Thrown as a TypeError by bru.utils.minifyXml when the input is not a string and not null/undefined. The function accepts only strings (and rejects null/undefined with 'Failed to minify'); any other type (number, boolean, object, symbol) falls through to the TypeError at bru.js:138.
Source
Thrown at packages/bruno-js/src/bru.js:138
}
throw new TypeError('minifyJson expects a string or object');
},
minifyXml: (xml) => {
if (xml === null || xml === undefined) {
throw new Error('Failed to minify');
}
if (typeof xml === 'string') {
try {
return xmlFormat(xml, { collapseContent: false, indentation: '', lineSeparator: '' });
} catch (err) {
throw new Error(`Failed to minify: ${err?.message || err}`);
}
}
throw new TypeError('minifyXml expects a string');
}
};
}
interpolate = (strOrObj) => {
if (!strOrObj) return strOrObj;
const isObj = typeof strOrObj === 'object';
const strToInterpolate = isObj ? JSON.stringify(strOrObj) : strOrObj;
const combinedVars = {
...this.globalEnvironmentVariables,
...this.collectionVariables,
...this.envVariables,
...this.folderVariables,
...this.requestVariables,
...this.oauth2CredentialVariables,
...this.runtimeVariables,
...this.promptVariables,View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Ensure the input is a string; if it is an object, serialize it first.
- Check typeof xml === 'string' before calling minifyXml.
- If you have a DOM object, call its serialize method (e.g., XMLSerializer) to get a string first.
Example fix
// before const min = bru.utils.minifyXml(res.getBody()); // returns an object, not a string // after const body = res.getBody(); const xmlStr = typeof body === 'string' ? body : JSON.stringify(body); const min = bru.utils.minifyXml(xmlStr);
Defensive patterns
Strategy: type-guard
Validate before calling
function isStringInput(val) {
return typeof val === 'string';
}
// before calling: if (isStringInput(val)) bru.utils.minifyXml(val); Type guard
function isMinifiableXmlInput(val) {
return typeof val === 'string';
} Prevention
- Ensure the XML input is a string, not a parsed DOM object.
- Serialize objects to strings before passing to minifyXml.
- Check typeof val === 'string' before calling minifyXml.
When it happens
Trigger: Calling bru.utils.minifyXml(42), bru.utils.minifyXml(true), bru.utils.minifyXml({ root: 'data' }), or bru.utils.minifyXml(() => {}). The typeof xml check at bru.js:130 only matches 'string'.
Common situations: Passing a parsed XML DOM object instead of the serialized XML string. Passing a numeric status code or boolean flag by mistake. Passing a response body object when the raw string was intended.
Related errors
- minifyJson expects a string or object
- ${callback} is not a function
- Invalid arguments passed to setCookie
- setCookies expects an array of cookie objects
- Workspace path not found
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/3be297a7c41add93.
Report an issue: GitHub.