{"record":{"id":"3be297a7c41add93","repo":"usebruno/bruno","slug":"minifyxml-expects-a-string","errorCode":null,"errorMessage":"minifyXml expects a string","messagePattern":"minifyXml expects a string","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/bruno-js/src/bru.js","lineNumber":138,"sourceCode":"        }\n\n        throw new TypeError('minifyJson expects a string or object');\n      },\n\n      minifyXml: (xml) => {\n        if (xml === null || xml === undefined) {\n          throw new Error('Failed to minify');\n        }\n\n        if (typeof xml === 'string') {\n          try {\n            return xmlFormat(xml, { collapseContent: false, indentation: '', lineSeparator: '' });\n          } catch (err) {\n            throw new Error(`Failed to minify: ${err?.message || err}`);\n          }\n        }\n\n        throw new TypeError('minifyXml expects a string');\n      }\n    };\n  }\n\n  interpolate = (strOrObj) => {\n    if (!strOrObj) return strOrObj;\n    const isObj = typeof strOrObj === 'object';\n    const strToInterpolate = isObj ? JSON.stringify(strOrObj) : strOrObj;\n\n    const combinedVars = {\n      ...this.globalEnvironmentVariables,\n      ...this.collectionVariables,\n      ...this.envVariables,\n      ...this.folderVariables,\n      ...this.requestVariables,\n      ...this.oauth2CredentialVariables,\n      ...this.runtimeVariables,\n      ...this.promptVariables,","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-js/src/bru.js#L120-L156","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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."],"exampleFix":"// before\nconst min = bru.utils.minifyXml(res.getBody()); // returns an object, not a string\n\n// after\nconst body = res.getBody();\nconst xmlStr = typeof body === 'string' ? body : JSON.stringify(body);\nconst min = bru.utils.minifyXml(xmlStr);","handlingStrategy":"type-guard","validationCode":"function isStringInput(val) {\n  return typeof val === 'string';\n}\n// before calling: if (isStringInput(val)) bru.utils.minifyXml(val);","typeGuard":"function isMinifiableXmlInput(val) {\n  return typeof val === 'string';\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["xml","minify","type-error","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}