{"record":{"id":"fb37df835203bb8d","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-parse-test-file-file","errorCode":null,"errorMessage":"Failed to parse test file: {file}","messagePattern":"Failed to parse test file: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/DocumentExtractorNode.java","lineNumber":110,"sourceCode":"\t\telse {\n\t\t\turi = Paths.get(filePath).toUri();\n\t\t}\n\n\t\tif (uri.getScheme().equals(\"file\")) {\n\t\t\treturn new BufferedInputStream(Files.newInputStream(Paths.get(uri)));\n\t\t}\n\t\telse {\n\t\t\treturn new BufferedInputStream(uri.toURL().openStream());\n\t\t}\n\t}\n\n\tprivate List<String> getDocument(List<String> fileList) {\n\t\treturn fileList.stream().map(String::trim).map(file -> {\n\t\t\ttry (InputStream inputStream = this.getInputStream(file.trim())) {\n\t\t\t\treturn this.extractTextByFileExtension(inputStream, getFileExtension(file));\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new RuntimeException(\"Failed to parse test file: \" + file, e);\n\t\t\t}\n\t\t}).toList();\n\t}\n\n\t@Override\n\tpublic Map<String, Object> apply(OverAllState state) throws Exception {\n\t\tif (paramsKey == null && fileList == null) {\n\t\t\tthrow new RuntimeException(\"File variable not found for selector\");\n\t\t}\n\t\tList<String> fileList;\n\t\tObject fileObj = state.value(paramsKey).orElse(this.fileList);\n\t\tif (this.inputIsArray) {\n\t\t\tif (fileObj instanceof List<?>) {\n\t\t\t\tfileList = (List<String>) fileObj;\n\t\t\t}\n\t\t\telse if (fileObj instanceof String[]) {\n\t\t\t\tfileList = Arrays.asList((String[]) fileObj);\n\t\t\t}","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/DocumentExtractorNode.java#L92-L128","documentation":"DocumentExtractorNode.getDocument throws this RuntimeException when extracting text from a file in the file list fails — the input stream could not be opened or extractTextByFileExtension could not parse the content for that file's extension. The original exception is wrapped with the offending file path.","triggerScenarios":"A file listed in the state's file list cannot be read (missing resource, bad URL/path, permission) or its extension does not match its actual format so the Tika/extension-based parser fails.","commonSituations":"Unsupported or misnamed extensions (.docx passed as .txt); files uploaded as ArraryFileSegment with broken URLs; temporary files deleted before extraction; network-hosted files unreachable at parse time.","solutions":["Read the wrapped cause to identify whether it's an open failure or parse failure","Fix the file's extension or convert it to a supported format","Verify the file exists/is accessible at extraction time (check URLs, permissions)","Pre-validate files (existence + extension) before running the workflow"],"exampleFix":"// before\nfiles.add(\"/data/report.pdf.txt\"); // wrong extension\n// after\nfiles.add(\"/data/report.pdf\");","handlingStrategy":"try-catch","validationCode":"for (String f : files) {\n    try (InputStream in = getInputStream(f)) { /* probe readable */ }\n    catch (Exception e) { throw new PrecheckException(\"unreadable file: \" + f, e); }\n}","typeGuard":null,"tryCatchPattern":"try {\n    result = extractorNode.apply(state);\n} catch (RuntimeException e) {\n    logger.error(\"Extraction failed: {}\", e.getMessage(), e.getCause());\n    state.put(outputKey, List.of());\n}","preventionTips":["Pre-validate file existence, permissions, and extension before extraction","Keep file extensions accurate and convert unsupported formats upstream","Read the wrapped cause — it distinguishes open failures from parse failures"],"tags":["document-extraction","file-parsing","file-read"],"backgroundTag":"file-read-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}