{"record":{"id":"659232a73656a15e","repo":"apache/hadoop","slug":"bad-framework-group-name-name","errorCode":null,"errorMessage":"bad framework group name: ${name}","messagePattern":"bad framework group name: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/CounterGroupFactory.java","lineNumber":166,"sourceCode":"  }\n\n  /**\n   * Check whether a group name is a name of a framework group (including\n   * the filesystem group).\n   *\n   * @param name  to check\n   * @return true for framework group names\n   */\n  public static synchronized boolean isFrameworkGroup(String name) {\n    return s2i.get(name) != null || name.equals(FS_GROUP_NAME);\n  }\n\n  private static void throwBadFrameGroupIdException(int id) {\n    throw new IllegalArgumentException(\"bad framework group id: \"+ id);\n  }\n\n  private static void throwBadFrameworkGroupNameException(String name) {\n    throw new IllegalArgumentException(\"bad framework group name: \"+ name);\n  }\n\n  /**\n   * Abstract factory method to create a generic (vs framework) counter group\n   * @param name  of the group\n   * @param displayName of the group\n   * @param limits limits of the counters\n   * @return a new generic counter group\n   */\n  protected abstract G newGenericGroup(String name, String displayName,\n                                       Limits limits);\n\n  /**\n   * Abstract factory method to create a file system counter group\n   * @return a new file system counter group\n   */\n  protected abstract G newFileSystemGroup();\n}","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/counters/CounterGroupFactory.java#L148-L184","documentation":"The string counterpart of the id lookup: CounterGroupFactory resolves group names to framework group objects through a name-to-group map (s2i, plus the FS group name). throwBadFrameworkGroupNameException throws IllegalArgumentException when a name is not a registered framework group name, i.e. the factory was asked to create a framework group for a name that is actually generic (or unknown).","triggerScenarios":"Internal code paths that call newFrameworkGroup(String name) (or equivalent lookups) with a name that is neither in the framework registry nor FS_GROUP_NAME - e.g. passing \"MyCustomGroup\" where only names like \"org.apache.hadoop.mapreduce.TaskCounter\" or the filesystem group name are valid.","commonSituations":"Custom code or reflection reaching into the private CounterGroupFactory API; forks that renamed framework groups; copying internal code that assumes any counter group name is a framework group.","solutions":["Use the public API: counters.getGroup(name)/findCounter(group, name) route framework names to framework groups and everything else to generic groups automatically.","If you must touch the factory, gate the call with CounterGroupFactory.isFrameworkGroup(name) first.","In forks, register renamed/added groups in the factory map before use."],"exampleFix":"// before (internal API misuse)\nG group = factory.newFrameworkGroup(\"MyCustomGroup\"); // IllegalArgumentException\n\n// after (public API routes generic names correctly)\nCounters counters = new Counters();\nCounter c = counters.findCounter(\"MyCustomGroup\", \"MY_COUNTER\");","handlingStrategy":"validation","validationCode":"String name = ...;\nif (!CounterGroupFactory.isFrameworkGroup(name)) {\n  // generic group path - use public counters API instead of the factory\n  counters.findCounter(name, \"MY_COUNTER\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Counters.getGroup/findCounter, which routes names correctly; avoid the internal factory.","Test custom counters code against both framework and generic group names."],"tags":["hadoop","mapreduce","counters","illegalargument","name-lookup"],"backgroundTag":"unknown-name-lookup","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}