{"record":{"id":"bcece28de0eecdbc","repo":"json-path/JsonPath","slug":"no-results-for-path-bcece2","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/PathToken.java","lineNumber":66,"sourceCode":"            String property = properties.get(0);\n            String evalPath = Utils.concat(currentPath, \"['\", property, \"']\");\n            Object propertyVal = readObjectProperty(property, model, ctx);\n            if(propertyVal == JsonProvider.UNDEFINED){\n                // Conditions below heavily depend on current token type (and its logic) and are not \"universal\",\n                // so this code is quite dangerous (I'd rather rewrite it & move to PropertyPathToken and implemented\n                // WildcardPathToken as a dynamic multi prop case of PropertyPathToken).\n                // Better safe than sorry.\n                assert this instanceof PropertyPathToken : \"only PropertyPathToken is supported\";\n\n                if(isLeaf()) {\n                    if(ctx.options().contains(Option.DEFAULT_PATH_LEAF_TO_NULL)){\n                        propertyVal =  null;\n                    } else {\n                        if(ctx.options().contains(Option.SUPPRESS_EXCEPTIONS) ||\n                           !ctx.options().contains(Option.REQUIRE_PROPERTIES)){\n                            return;\n                        } else {\n                            throw new PathNotFoundException(\"No results for path: \" + evalPath);\n                        }\n                    }\n                } else {\n                    if (! (isUpstreamDefinite() && isTokenDefinite()) &&\n                       !ctx.options().contains(Option.REQUIRE_PROPERTIES) ||\n                       ctx.options().contains(Option.SUPPRESS_EXCEPTIONS)){\n                        // If there is some indefiniteness in the path and properties are not required - we'll ignore\n                        // absent property. And also in case of exception suppression - so that other path evaluation\n                        // branches could be examined.\n                        return;\n                    } else {\n                        throw new PathNotFoundException(\"Missing property in path \" + evalPath);\n                    }\n                }\n            }\n            PathRef pathRef = ctx.forUpdate() ? PathRef.create(model, property) : PathRef.NO_OP;\n            if (isLeaf()) {\n                String idx = \"[\" + String.valueOf(upstreamArrayIndex) + \"]\";","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathToken.java#L48-L84","documentation":"PathNotFoundException thrown by PathToken.handleObjectProperty when a property does not resolve during evaluation, neither SUPPRESS_EXCEPTIONS nor REQUIRE_PROPERTIES handling applies to silently skip it, and the token/upstream is considered definite — meaning the path pointed at a value that simply does not exist in the document.","triggerScenarios":"JsonPath.read(json, \"$.user.email\") where 'email' key is absent from the JSON and no Option.AS_PATH_LIST/DEFAULT_PATH_LEAF_TO_NULL is set; reading a definite path against an incomplete document.","commonSituations":"API responses missing optional fields, documents from different schema versions, tests expecting a key that the fixture omits.","solutions":["Check the JSON actually contains the property at that path before reading","Add Option.REQUIRE_PROPERTIES awareness: configure Option.DEFAULT_PATH_LEAF_TO_NULL to get null instead of an exception","Add Option.SUPPRESS_EXCEPTIONS to return an empty result instead of throwing","Catch PathNotFoundException and treat it as a missing value in the caller"],"exampleFix":"// before\nString email = JsonPath.read(json, \"$.user.email\");\n// after\nConfiguration cfg = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build();\nString email = JsonPath.using(cfg).parse(json).read(\"$.user.email\", String.class);","handlingStrategy":"try-catch","validationCode":"Object v = null;\ntry { v = JsonPath.parse(json).read(path); } catch (PathNotFoundException ignored) {}\nboolean exists = v != null;","typeGuard":null,"tryCatchPattern":"try {\n    String val = JsonPath.read(json, \"$.user.email\");\n} catch (PathNotFoundException e) {\n    String val = null; // treat as absent field\n}","preventionTips":["Configure Option.SUPPRESS_EXCEPTIONS or Option.DEFAULT_PATH_LEAF_TO_NULL for tolerant reads","Remember properties are required by default in jayway JsonPath","Validate document shape against expected schema before querying optional fields","Centralize reads in a helper that handles PathNotFoundException"],"tags":["json-path","path-not-found","missing-property","evaluation"],"backgroundTag":"resource-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"}