{"record":{"id":"0420e4283c1ea07b","repo":"karatelabs/karate","slug":"inputfile-file-not-found-ref-resolved-to-path-a-bare-path-is","errorCode":null,"errorMessage":"inputFile: file not found: {ref} (resolved to: {path}) — 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: (.+?) \\(resolved to: (.+?)\\) — 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":181,"sourceCode":"        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    }\n\n    /**\n     * Adapt a JS/Java callable argument to a {@code Supplier<Object>}.\n     * <p>Karate treats inline JS lambdas as first-class Java callables — the\n     * same pattern that powers {@code karate.filter(list, x => ...)}.\n     * This helper lets driver bindings route a callable argument to the\n     * {@code Supplier}-taking overload of a method (polled locally in\n     * karate-js) rather than coercing it to a string and shipping it off to","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/driver/DriverApi.java#L163-L199","documentation":"Thrown by DriverApi.resolveFilePath (via fileNotFoundMessage) when the ref resolved to a candidate local path but the file does not exist. Unlike the unresolvable-path variant, this includes the resolved path so you can see exactly where Karate looked.","triggerScenarios":"driver.inputFile(ref, ...) where ref resolved (feature-relative or project-root) to a concrete local path but no file exists there; wrong filename, wrong directory, file deleted by a clean build, or the leading '/' anchoring to an unexpected root.","commonSituations":"Files under src/test/resources not on the runtime classpath, features moved between directories, clean builds wiping generated fixtures, case-sensitivity mismatches on Linux.","solutions":["Check the '(resolved to: ...)' path in the message and verify the file exists there","Fix the relative path or use a leading '/' to anchor at the project root","Use the 'file:' prefix with an absolute host path as a last resort","Ensure fixture files are in the classpath output (target/test-classes) at test time"],"exampleFix":"// before\ndriver.inputFile(\"fixtures/photo.png\", \"#upload\"); // resolved to wrong dir\n// after\ndriver.inputFile(\"/src/test/resources/fixtures/photo.png\", \"#upload\");\n// or absolute:\ndriver.inputFile(\"file:/home/dev/fixtures/photo.png\", \"#upload\");","handlingStrategy":"validation","validationCode":"String resolved = featureDir.resolve(\"fixtures/photo.png\").normalize().toString();\nif (!java.nio.file.Files.exists(java.nio.file.Paths.get(resolved))) {\n    throw new IllegalStateException(\"fixture missing at: \" + resolved);\n}\ndriver.inputFile(resolved, \"#upload\");","typeGuard":null,"tryCatchPattern":"try {\n    driver.inputFile(ref, \"#upload\");\n} catch (DriverException e) {\n    if (e.getMessage().contains(\"(resolved to:\")) {\n        String lookedAt = e.getMessage().replaceAll(\".*resolved to: ([^)]+)\\).*\", \"$1\");\n        System.err.println(\"Karate looked at: \" + lookedAt);\n    } throw e;\n}","preventionTips":["Read the '(resolved to: ...)' hint in the message and check that exact path","Mind Linux case sensitivity in file names","Anchor with leading '/' for project-root files","Confirm fixtures are copied to target/test-classes"],"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"}