{"record":{"id":"3a4389cd56cfd31a","repo":"karatelabs/karate","slug":"inputfile-file-not-found-ref-a-bare-path-is-relative-to-the","errorCode":null,"errorMessage":"inputFile: file not found: {ref} — a bare path is relative to the feature, a leading '/' anchors the project root, 'file:' is a host machine path","messagePattern":"inputFile: file not found: (.+?) — a bare path is relative to the feature, a leading '/' anchors the project root, 'file:' is a host machine path","errorType":"exception","errorClass":"DriverException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/driver/DriverApi.java","lineNumber":173,"sourceCode":"        List<String> files = new ArrayList<>(refs.length);\n        for (String ref : refs) {\n            files.add(resolveFilePath(ref));\n        }\n        return files;\n    }\n\n    private static String resolveFilePath(String ref) {\n        if (ref.startsWith(Resource.FILE_COLON)) {\n            return Path.of(Resource.removePrefix(ref)).toAbsolutePath().normalize().toString();\n        }\n        ScenarioRuntime runtime = ScenarioRuntime.currentOrNull();\n        Resource resource;\n        try {\n            resource = runtime != null && runtime.getFeatureRuntime() != null\n                    ? runtime.getFeatureRuntime().resolve(ref)\n                    : Resource.path(ref);\n        } catch (Exception e) {\n            throw new DriverException(fileNotFoundMessage(ref, null), e);\n        }\n        Path path = resource.isFile() ? resource.getPath() : null;\n        if (path == null || path.getFileSystem() != FileSystems.getDefault()) {\n            throw new DriverException(\"inputFile: not a local file: \" + ref\n                    + \" — the browser needs a real file on disk; extract it first, or point at it with 'file:'\");\n        }\n        if (!resource.exists()) {\n            throw new DriverException(fileNotFoundMessage(ref, path));\n        }\n        return path.toAbsolutePath().normalize().toString();\n    }\n\n    private static String fileNotFoundMessage(String ref, Path resolved) {\n        return \"inputFile: file not found: \" + ref\n                + (resolved == null ? \"\" : \" (resolved to: \" + resolved.toAbsolutePath().normalize() + \")\")\n                + \" — a bare path is relative to the feature, a leading '/' anchors the project root,\"\n                + \" 'file:' is a host machine path\";\n    }","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/DriverApi.java#L155-L191","documentation":"Thrown by DriverApi.resolveFilePath when the inputFile path reference cannot be resolved at all — neither through the feature's resource resolver nor as a plain host path. Karate distinguishes feature-relative paths, project-root paths (leading '/'), and host machine paths ('file:' prefix); the ref matched none.","triggerScenarios":"Calling driver.inputFile(ref, ...) with a typo'd or missing path; ref is a bare path relative to a feature directory where the file is not present; using an in-memory/jar resource where FeatureRuntime resolution fails and Resource.path(ref) also fails.","commonSituations":"Test resources not copied into the target/classpath location, running tests from a different working directory, refactoring moved the feature but not the fixture files, attempting to input files that exist only inside a jar or on a remote filesystem.","solutions":["Fix the path: bare path relative to the feature, leading '/' for project root, 'file:' for a host machine path","Verify the file exists on disk at the expected location","Place the file under src/test/resources (or alongside the feature) so it is on the classpath","Pre-extract jar/remote resources to a real temp file and pass a 'file:' path"],"exampleFix":"// before\ndriver.inputFile(\"upload.txt\", \"#fileInput\");\n// after\ndriver.inputFile(\"file:\" + \"/absolute/path/upload.txt\", \"#fileInput\");","handlingStrategy":"validation","validationCode":"java.nio.file.Path p = java.nio.file.Paths.get(\"src/test/resources/upload.txt\");\nif (!java.nio.file.Files.exists(p)) {\n    throw new IllegalStateException(\"input file missing: \" + p.toAbsolutePath());\n}\ndriver.inputFile(\"file:\" + p.toAbsolutePath(), \"#fileInput\");","typeGuard":null,"tryCatchPattern":"try {\n    driver.inputFile(ref, \"#fileInput\");\n} catch (DriverException e) {\n    if (e.getMessage().startsWith(\"inputFile: file not found\")) {\n        throw new IllegalStateException(\"Fix ref: bare=feature-relative, '/'=project root, 'file:'=host path. \" + e.getMessage(), e);\n    } throw e;\n}","preventionTips":["Keep upload fixtures next to the feature or under src/test/resources","Prefer feature-relative paths; use 'file:' only for host-absolute paths","Don't reference classpath/jar resources directly for inputFile","Verify files survive mvn clean"],"tags":["driver","file-upload","path-resolution"],"backgroundTag":"file-not-found","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}