{"record":{"id":"0b91edef8b841bc4","repo":"neo4j/neo4j","slug":"invalid-tag-tag-must-be-in-the-format-key-val","errorCode":null,"errorMessage":"Invalid tag. Tag must be in the format '<key>:<value>'! Provided: '%s'","messagePattern":"Invalid tag\\. Tag must be in the format '<key>:<value>'! Provided: '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"community/cloud/src/main/java/org/neo4j/cloud/storage/StorageTag.java","lineNumber":40,"sourceCode":"import java.nio.file.Path;\nimport java.util.Collection;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.regex.PatternSyntaxException;\nimport java.util.stream.Collectors;\n\npublic record StorageTag(String key, String value) {\n    public static final String STORAGE_TAGS = \"storage_tags\";\n\n    public static StorageTag parse(String input) {\n        if (input == null || input.isEmpty()) {\n            throw new IllegalArgumentException(\"Invalid tag. Tag must not be empty or null!\");\n        }\n\n        try {\n            var inputSplit = input.split(\":\");\n            if (inputSplit.length != 2) {\n                throw new IllegalArgumentException(\n                        String.format(\"Invalid tag. Tag must be in the format '<key>:<value>'! Provided: '%s'\", input));\n            }\n            return new StorageTag(inputSplit[0], inputSplit[1]);\n        } catch (PatternSyntaxException e) {\n            throw new IllegalArgumentException(\n                    String.format(\"Invalid tag. Tag must be in the format '<key>:<value>'! Provided: '%s'\", input));\n        }\n    }\n\n    public static void setTags(Path path, Collection<StorageTag> tags) {\n        if (!tags.isEmpty()) {\n            if (path instanceof StoragePath storagePath) {\n                storagePath.addMetadata(STORAGE_TAGS, tags);\n            } else {\n                throw new IllegalArgumentException(\"Cannot set tags on path which doesn't point to Object Storage\");\n            }\n        }\n    }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/neo4j/neo4j/blob/f213380f812b820a1b312e2ea52cb3d8f1931ccc/community/cloud/src/main/java/org/neo4j/cloud/storage/StorageTag.java#L22-L58","documentation":"StorageTag.parse throws IllegalArgumentException when input.split(\":\") does not yield exactly two parts. The tag format is strictly '<key>:<value>' — one colon. Inputs with no colon ('keyvalue') or multiple colons ('k:v:extra', which splits into 3 parts) are rejected.","triggerScenarios":"StorageTag.parse(\"tag\") (no colon); StorageTag.parse(\"a:b:c\") (two colons → length 3); values containing colons such as URIs or timestamps ('key:https://x') which also split into more than 2 parts.","commonSituations":"Tag values that legitimately contain colons (URLs, key=value query strings, clock times); users writing 'key=value' instead of 'key:value'; copy-paste of ARNs or endpoints as tag values.","solutions":["Rewrite the tag as exactly one colon: '<key>:<value>'","If the value contains colons, encode or escape it, or split on first occurrence manually rather than via StorageTag.parse","Validate with a regex like ^[^:]+:[^:]*$ before parsing and reject with a helpful message"],"exampleFix":"// before\nStorageTag t = StorageTag.parse(\"endpoint:https://neo4j.example.com\");\n\n// after\nint idx = input.indexOf(':');\nStorageTag t = (idx > 0)\n        ? new StorageTag(input.substring(0, idx), input.substring(idx + 1))\n        : StorageTag.parse(input); // let parse() reject truly malformed input","handlingStrategy":"validation","validationCode":"private static final Pattern TAG = Pattern.compile(\"^([^:]+):([^:]*)$\");\nboolean ok = TAG.matcher(input).matches();","typeGuard":"static boolean isValidTagFormat(String s) { return s != null && s.split(\":\", -1).length == 2 && !s.split(\":\", -1)[0].isEmpty(); }","tryCatchPattern":"try { return StorageTag.parse(input); } catch (IllegalArgumentException e) { throw new ConfigurationException(\"Bad storage tag '\" + input + \"', expected <key>:<value>\", e); }","preventionTips":["For values containing colons, split on the first colon yourself and construct the record","Document the single-colon rule wherever tag settings are exposed"],"tags":["neo4j","cloud-storage","tags","parsing","validation"],"backgroundTag":null,"analyzedSha":"f213380f812b820a1b312e2ea52cb3d8f1931ccc","analyzedAt":"2026-08-14T15:32:33.859Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}