{"record":{"id":"5f4f9a6b8c06723f","repo":"FasterXML/jackson-databind","slug":"argument-allowedschemes-must-not-be-null","errorCode":null,"errorMessage":"Argument `allowedSchemes` must not be null","messagePattern":"Argument `allowedSchemes` must not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/jdk/JDKFromStringDeserializer.java","lineNumber":402,"sourceCode":"\n        public NioPathDeserializer() { this(DEFAULT_ALLOWED_SCHEMES); }\n\n        /**\n         * Constructor for specifying URI schemes to accept: matching is done\n         * case-insensitively, same as by {@code java.nio.file.Path.of(URI)}.\n         *<p>\n         * NOTE: for allowed schemes that have no provider installed for the system\n         * class loader, look up is also attempted using this thread's context class\n         * loader (see [databind#2120]); this is never done for schemes that are not\n         * allowed.\n         *\n         * @param allowedSchemes URI schemes to accept; must not be {@code null}\n         *   (but may be empty to only accept scheme-less values)\n         */\n        public NioPathDeserializer(Collection<String> allowedSchemes) {\n            super(Path.class, -1);\n            if (allowedSchemes == null) {\n                throw new IllegalArgumentException(\"Argument `allowedSchemes` must not be null\");\n            }\n            _allowedSchemes = allowedSchemes;\n        }\n\n        @Override\n        public Object _deserialize(String value, DeserializationContext ctxt) throws JacksonException {\n            return deserialize(ctxt, value, _allowedSchemes);\n        }\n\n        public static Path deserialize(DeserializationContext ctxt, String value,\n                Collection<String> allowedSchemes) throws JacksonException {\n            // If someone gives us an input with no : at all, treat as local path,\n            // instead of failing with invalid URI.\n\n            int colonIx = value.indexOf(':');\n            if (colonIx < 0) {\n                return Path.of(value);\n            }","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/jdk/JDKFromStringDeserializer.java#L384-L420","documentation":"Thrown by the NioPathDeserializer(Collection<String> allowedSchemes) constructor when the allowedSchemes argument is null. This deserializer (for java.nio.file.Path values, introduced in [databind#6129]) explicitly rejects null scheme collections because URI scheme validation requires a definitive set (possibly empty, meaning scheme-less values only, but never null). This is a programmer-error guard, not a data-driven exception.","triggerScenarios":"Directly constructing new NioPathDeserializer(null) in custom module code. A custom module or SimpleModule.addDeserializer call that passes null for the schemes parameter. A builder pattern that accidentally leaves the schemes unset.","commonSituations":"Registering a custom Path deserializer via a module without providing the allowed schemes. Copy-paste from example code that omits the argument. Migration from the default constructor to the custom-schemes constructor where null is passed instead of DEFAULT_ALLOWED_SCHEMES.","solutions":["Pass NioPathDeserializer.DEFAULT_ALLOWED_SCHEMES (or Collections.singletonList(\"file\")) when you want the default behavior.","Pass an empty collection (Collections.emptyList()) if you only want to accept scheme-less paths.","If allowing custom schemes, provide them explicitly as a non-null collection.","Use the no-arg NioPathDeserializer() constructor for default behavior."],"exampleFix":"// before\nnew NioPathDeserializer(null)\n// after\nnew NioPathDeserializer(NioPathDeserializer.DEFAULT_ALLOWED_SCHEMES)","handlingStrategy":"validation","validationCode":"// Never pass null; use default or empty\nCollection<String> schemes = (schemes == null)\n    ? NioPathDeserializer.DEFAULT_ALLOWED_SCHEMES : schemes;\nnew NioPathDeserializer(schemes);","typeGuard":"Objects.requireNonNull(allowedSchemes, \"allowedSchemes must not be null\");","tryCatchPattern":null,"preventionTips":["Never pass null for allowedSchemes — use DEFAULT_ALLOWED_SCHEMES or emptyList().","Use the no-arg constructor for default behavior.","Validate non-null in builder patterns."],"tags":["jackson","deserialization","path","null-argument","uri-scheme"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}