{"record":{"id":"ab8dcc9848ee0584","repo":"usebruno/bruno","slug":"failed-to-parse-the-file-ensure-it-is-valid-json","errorCode":null,"errorMessage":"Failed to parse the file – ensure it is valid JSON or YAML","messagePattern":"Failed to parse the file – ensure it is valid JSON or YAML","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/components/Sidebar/ImportCollection/FileTab.js","lineNumber":32,"sourceCode":"  const text = await file.text();\n\n  // Handle WSDL files - return as plain text\n  if (file.name.endsWith('.wsdl') || file.type === 'text/xml' || file.type === 'application/xml') {\n    return text;\n  }\n\n  try {\n    if (file.type === 'application/json' || file.name.endsWith('.json')) {\n      return JSON.parse(text);\n    }\n\n    const parsed = jsyaml.load(text, { schema: jsyaml.JSON_SCHEMA });\n    if (typeof parsed !== 'object' || parsed === null) {\n      throw new Error();\n    }\n    return parsed;\n  } catch {\n    throw new Error('Failed to parse the file – ensure it is valid JSON or YAML');\n  }\n};\n\nconst FileTab = ({\n  setIsLoading,\n  handleSubmit,\n  setErrorMessage\n}) => {\n  const [dragActive, setDragActive] = useState(false);\n  const fileInputRef = useRef(null);\n  const { theme } = useTheme();\n\n  const acceptedFileTypes = [\n    '.json',\n    '.yaml',\n    '.yml',\n    '.wsdl',\n    '.zip',","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/components/Sidebar/ImportCollection/FileTab.js#L14-L50","documentation":"Error \"Failed to parse the file – ensure it is valid JSON or YAML\" thrown in usebruno/bruno.","triggerScenarios":"Thrown at packages/bruno-app/src/components/Sidebar/ImportCollection/FileTab.js:32 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Open the file in an editor and validate its JSON/YAML syntax.","Fix syntax errors (trailing commas, bad indentation) and retry the import."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}