{"record":{"id":"454c03d332b1e4c4","repo":"json-path/JsonPath","slug":"no-results-for-path","errorCode":null,"errorMessage":"No results for path: ","messagePattern":"No results for path: ","errorType":"exception","errorClass":"PathNotFoundException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/path/EvaluationContextImpl.java","lineNumber":142,"sourceCode":"        return Collections.unmodifiableCollection(updateOperations);\n    }\n\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T> T getValue() {\n        return getValue(true);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T> T getValue(boolean unwrap) {\n        if (path.isDefinite()) {\n            if(resultIndex == 0) {\n                if (suppressExceptions) {\n                    return null;\n                }\n                throw new PathNotFoundException(\"No results for path: \" + path.toString());\n            }\n            int len = jsonProvider().length(valueResult);\n            Object value = (len > 0) ? jsonProvider().getArrayIndex(valueResult, len-1) : null;\n            if (value != null && unwrap){\n              value = jsonProvider().unwrap(value);\n            }\n            return (T) value;\n        }\n        return (T)valueResult;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T> T getPath() {\n        if(resultIndex == 0) {\n            if (suppressExceptions) {\n                return null;\n            }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/path/EvaluationContextImpl.java#L124-L160","documentation":"EvaluationContextImpl.getValue on a definite (single-result) path throws PathNotFoundException when the evaluation produced zero results — the path simply did not match anything in the document. Unlike indefinite paths, there is no list to be empty; a definite miss is fatal unless exceptions are suppressed.","triggerScenarios":"JsonPath.read(json, \"$.user.email\") where `email` key is absent; index out of range like `$.items[5]` on a shorter array; a filter that matched nothing on a definite path.","commonSituations":"Optional fields missing in API responses; case-sensitive key mismatches; documents older than new schema fields; reading config keys that were renamed.","solutions":["Add Option.SUPPRESS_EXCEPTIONS to the Configuration (or use JsonPath.parse(...).read with a default via `path(json).read` + null check).","Verify the path matches the actual document structure (print the document or use $..key to check existence).","Use JsonPathOptional / try-catch PathNotFoundException and supply a default value.","For possibly-missing keys, make the path indefinite, e.g. `$.user.email` → `$..email` with ALWAYS_RETURN_LIST."],"exampleFix":"// before\nString email = JsonPath.read(json, \"$.user.email\"); // throws when missing\n// after\nConfiguration cfg = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build();\nString email = JsonPath.using(cfg).parse(json).read(\"$.user.email\", String.class);\nif (email == null) email = \"\";","handlingStrategy":"try-catch","validationCode":"boolean pathExists(DocumentContext ctx, String path) {\n    Configuration cfg = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS, Option.AS_PATH_LIST).build();\n    return !JsonPath.using(cfg).parse(ctx.json()).read(path, List.class).isEmpty();\n}","typeGuard":null,"tryCatchPattern":"try {\n    return JsonPath.read(json, \"$.user.email\");\n} catch (PathNotFoundException e) {\n    return defaultValue;\n}","preventionTips":["Configure Option.SUPPRESS_EXCEPTIONS for optional fields.","Verify paths against a sample document during development.","Wrap reads of optional schema fields with defaults."],"tags":["json-path","path-not-found","evaluation","missing-value"],"backgroundTag":"record-not-found","analyzedSha":"62a4c9f0f65ba3f625aa0867d64c528ba72d09ec","analyzedAt":"2026-09-11T11:36:00.448Z","contentChangedAt":"2026-09-11T11:36:00.448Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}