{"record":{"id":"aad956e589914bde","repo":"stanfordnlp/CoreNLP","slug":"unknown-default-unit-entry-getvalue-first-for","errorCode":null,"errorMessage":"Unknown default unit ${entry.getValue().first} for ${entry.getKey()}","messagePattern":"Unknown default unit (.+?) for (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/ie/qe/Units.java","lineNumber":154,"sourceCode":"      }\n      if (fields.length > iDefaultUnit) {\n        double scale = 1.0;\n        if (fields.length > iDefaultUnitScale) {\n          scale = Double.parseDouble(fields[iDefaultUnitScale]);\n        }\n        unitToDefaultUnits.put(unit.getName(), Pair.makePair(fields[iDefaultUnit], scale));\n      }\n      unitsByName.put(unit.getName(), unit);\n      list.add(unit);\n    }\n    for (Map.Entry<String, Pair<String,Double>> entry: unitToDefaultUnits.entrySet()) {\n      Unit unit = unitsByName.get(entry.getKey());\n      Unit defaultUnit = unitsByName.get(entry.getValue().first);\n      if (defaultUnit != null) {\n        unit.defaultUnit = defaultUnit;\n        unit.defaultUnitScale = entry.getValue().second;\n      } else {\n        Redwood.Util.warn(\"Unknown default unit \" + entry.getValue().first + \" for \" + entry.getKey());\n      }\n    }\n    br.close();\n    return list;\n  }\n\n}\n","sourceCodeStart":136,"sourceCodeEnd":162,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/qe/Units.java#L136-L162","documentation":"When loading quantity-expressor units, each unit's declared default unit name is looked up in unitsByName. If the referenced default unit was never defined (or misspelled / loaded out of order), the link cannot be made and a warning is emitted; the unit is loaded without a defaultUnit.","triggerScenarios":"Units.loadUnits (invoked via the units setup) reading a units definition file whose default-unit column names a unit string not present in unitsByName at link time.","commonSituations":"Typo in the default unit name in a custom units file; referencing a unit defined in a different file that wasn't loaded; case mismatch since lookup is exact via the unitsByName map.","solutions":["Fix the default unit name in the units file to exactly match a defined unit's name.","Ensure the file defining the referenced unit is loaded before/along with the referencing file.","Check case sensitivity — unit names are matched exactly via unitsByName."],"exampleFix":"// before (units file): DEFAULT references misspelled 'kilometre' that doesn't exist\nmeter  LENGTH  metre  1.0  metres  m\n// after: define the referenced unit\nkilometre  LENGTH  kilometre  1000.0  kilometres  km\nmeter  LENGTH  metre  1.0  metres  m","handlingStrategy":"validation","validationCode":"Set<String> defined = unitsByName.keySet();\nfor (entry : defaults) {\n  if (!defined.contains(entry.getValue().first)) {\n    throw new IllegalArgumentException(\"Unknown default unit: \" + entry.getValue().first);\n  }\n}","typeGuard":null,"tryCatchPattern":"try (BufferedReader br = ...) {\n  return loadUnits(br);\n} catch (Exception e) {\n  log.warn(\"units file problem; continuing without default units\", e);\n  return Collections.emptyList();\n}","preventionTips":["Keep a canonical units file and lint it for name consistency.","Load all referenced unit files in the same run.","Match names exactly, including case."],"tags":["java","ner","config","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}