{"record":{"id":"b929b6256fd5034f","repo":"openzipkin/zipkin","slug":"key-null","errorCode":null,"errorMessage":"key == null","messagePattern":"key == null","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/CassandraAutocompleteTags.java","lineNumber":30,"sourceCode":"  final boolean enabled;\n  final Call<List<String>> keysCall;\n  final SelectAutocompleteValues.Factory valuesCallFactory;\n\n  CassandraAutocompleteTags(CassandraStorage storage) {\n    enabled = storage.searchEnabled\n      && !storage.autocompleteKeys.isEmpty()\n      && storage.metadata().hasAutocompleteTags;\n    keysCall = Call.create(List.copyOf(storage.autocompleteKeys));\n    valuesCallFactory = enabled ? new SelectAutocompleteValues.Factory(storage.session()) : null;\n  }\n\n  @Override public Call<List<String>> getKeys() {\n    if (!enabled) return Call.emptyList();\n    return keysCall.clone();\n  }\n\n  @Override public Call<List<String>> getValues(String key) {\n    if (key == null) throw new NullPointerException(\"key == null\");\n    if (key.isEmpty()) throw new IllegalArgumentException(\"key was empty\");\n    if (!enabled) return Call.emptyList();\n    return valuesCallFactory.create(key);\n  }\n}\n","sourceCodeStart":12,"sourceCodeEnd":36,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-storage/cassandra/src/main/java/zipkin2/storage/cassandra/CassandraAutocompleteTags.java#L12-L36","documentation":"CassandraAutocompleteTags.getValues(String) throws NullPointerException ('key == null') when a null tag key is passed to look up autocomplete tag values. The storage API requires a concrete tag key to query the autocomplete table, so null is rejected immediately rather than propagated into a Cassandra query.","triggerScenarios":"Calling storage.autocompleteTags().getValues(null), or passing a request parameter (e.g. from the Zipkin query API ?key=...) that was never validated before reaching storage.","commonSituations":"A UI or API client omits the key parameter and framework code forwards null; refactoring that removed an earlier null check; programmatic queries built from maps that may not contain the key.","solutions":["Pass a non-null tag key that is also in the configured autocompleteKeys list, e.g. getValues(\"env\")","Validate/skip the lookup at the caller when the key is null or empty","Fix the upstream request handler to reject missing key parameters with 400 instead of reaching storage"],"exampleFix":"// before\nCall<List<String>> values = storage.autocompleteTags().getValues(key); // key may be null\n\n// after\nif (key == null || key.isEmpty()) {\n  return Collections.emptyList(); // or return 400 to the caller\n}\nCall<List<String>> values = storage.autocompleteTags().getValues(key);","handlingStrategy":"type-guard","validationCode":"if (key == null || key.isEmpty()) { /* skip or return 400 */ }","typeGuard":"static boolean validAutocompleteKey(@Nullable String key) {\n  return key != null && !key.isEmpty();\n}","tryCatchPattern":null,"preventionTips":["Validate query parameters at the HTTP layer before they reach storage","Centralize null/empty checks for tag keys in one request-validation helper"],"tags":["zipkin","cassandra","autocomplete","null-check","query"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}