{"record":{"id":"37809eb7afb9a737","repo":"pinpoint-apm/pinpoint","slug":"nosuchelementexception-37809e","errorCode":null,"errorMessage":"NoSuchElementException","messagePattern":"NoSuchElementException","errorType":"exception","errorClass":"java.util.NoSuchElementException","httpStatus":null,"severity":"warning","filePath":"commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/trace/AnnotationKeyRegistry.java","lineNumber":89,"sourceCode":"            }\n        }\n        return table;\n    }\n\n    @Override\n    public AnnotationKey findAnnotationKey(int code) {\n        final AnnotationKey annotationKey = codeLookupTable.get(code);\n        if (annotationKey == null) {\n            return AnnotationKey.UNKNOWN;\n        }\n        return annotationKey;\n    }\n\n    @Override\n    public AnnotationKey findAnnotationKeyByName(String keyName) {\n        final AnnotationKey annotationKey = nameLookupTable.get(keyName);\n        if (annotationKey == null) {\n            throw new NoSuchElementException(keyName);\n        }\n        return annotationKey;\n    }\n\n    @Override\n    public AnnotationKey findApiErrorCode(int annotationCode) {\n        return this.apiErrorLookupTable.get(annotationCode);\n    }\n\n    static class Builder {\n\n        private final Map<Integer, AnnotationKey> buildMap = new HashMap<>();\n\n        void addAnnotationKey(AnnotationKey annotationKey) {\n            Objects.requireNonNull(annotationKey, \"annotationKey\");\n\n            int code = annotationKey.getCode();\n            final AnnotationKey exist = this.buildMap.put(code, annotationKey);","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/trace/AnnotationKeyRegistry.java#L71-L107","documentation":"findAnnotationKeyByName looks up an AnnotationKey by its display name in the registry's name table. When no key with that name is registered, the method throws NoSuchElementException rather than returning null — callers are expected to only query names that exist. The exception message is the missing key name itself.","triggerScenarios":"Calling findAnnotationKeyByName(\"...\") with a name that no registered AnnotationKey uses — a typo in the name, a key from a plugin that isn't loaded, or a name whose registration was skipped because the plugin failed to initialize.","commonSituations":"Metaspace/verification utilities (unregisteredAnnotationKeyTest, verifyAnnotationKey in the codebase) checking that keys referenced elsewhere are registered; UI/server code resolving annotation names from stored spans whose defining plugin is absent in this deployment.","solutions":["Use findAnnotationKeyByNameOrNull or check registration first if a lenient lookup is desired (check the AnnotationKeyRegistry API surface for the nullable variant)","Fix the key name string to match the registered AnnotationKey's getName() exactly","Ensure the plugin that defines the annotation key is actually loaded before querying","For optional lookups, wrap in try-catch on NoSuchElementException and handle absence"],"exampleFix":"// before\nAnnotationKey key = registry.findAnnotationKeyByName(\"unknown.key\"); // throws\n// after\nAnnotationKey key;\ntry {\n    key = registry.findAnnotationKeyByName(\"my.data\");\n} catch (NoSuchElementException e) {\n    key = AnnotationKey.UNKNOWN; // or log and skip\n}","handlingStrategy":"try-catch","validationCode":"AnnotationKey key = registry.findAnnotationKeyByNameOrNull(keyName); // lenient variant, if available\nif (key == null) {\n    LOGGER.warn(\"annotation key name not registered: {}\", keyName);\n}","typeGuard":"boolean isRegisteredKey(AnnotationKeyRegistry r, String name) {\n    try { r.findAnnotationKeyByName(name); return true; }\n    catch (NoSuchElementException e) { return false; }\n}","tryCatchPattern":"try {\n    AnnotationKey key = registry.findAnnotationKeyByName(keyName);\n} catch (NoSuchElementException e) {\n    // missing key name: use AnnotationKey.UNKNOWN or skip\n}","preventionTips":["Verify the exact registered name string (case-sensitive) before lookup","Ensure the owning plugin is on the classpath and initialized","Prefer a nullable/optional lookup API when the key may legitimately be absent"],"tags":["lookup-miss","registry","annotation"],"backgroundTag":"record-not-found","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}