{"record":{"id":"c0310cf568f03f3b","repo":"stanfordnlp/CoreNLP","slug":"the-annotator-header-property-is-set-to-true-but","errorCode":null,"errorMessage":"The annotator header property is set to true, but a different option has been provided for mapping file: ${mappingLine}","messagePattern":"The annotator header property is set to true, but a different option has been provided for mapping file: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java","lineNumber":271,"sourceCode":"            + \": Error opening the common words file: \" + commonWordsFile, ex);\n      }\n    }\n\n    String headerProp = properties.getProperty(prefix + \"mapping.header\", defaultHeader);\n    boolean readHeaderFromFile = headerProp.equalsIgnoreCase(\"true\");\n    String[] annotationFieldnames = null;\n    String[] headerFields = null;\n    if (readHeaderFromFile) {\n      annotationFieldnames = StringUtils.EMPTY_STRING_ARRAY;\n      annotationFields = new ArrayList<>();\n      // Set the read header property of each file to true\n      for (int i = 0; i < mappings.length; i++) {\n        String mappingLine = mappings[i];\n        if ( ! mappingLine.contains(\"header\")) {\n          mappingLine = \"header=true, \" + mappingLine;\n          mappings[i] = mappingLine;\n        } else if ( ! Pattern.compile(\"header\\\\s*=\\\\s*true\").matcher(mappingLine.toLowerCase()).find()) {\n          throw new IllegalStateException(\"The annotator header property is set to true, but a different option has been provided for mapping file: \" + mappingLine);\n        }\n      }\n\n    } else {\n      headerFields = COMMA_DELIMITERS_PATTERN.split(headerProp);\n      // Take header fields and remove known headers to get annotation field names\n      List<String> fieldNames = new ArrayList<>();\n      List<Class> fieldClasses = new ArrayList<>();\n      for (String field : headerFields) {\n        if ( ! predefinedHeaderFields.contains(field)) {\n          Class fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, field);\n          if (fieldClass == null) {\n            // check our properties\n            String classname = properties.getProperty(prefix + \"mapping.field.\" + field);\n            fieldClass = EnvLookup.lookupAnnotationKeyWithClassname(null, classname);\n          }\n          if (fieldClass != null) {\n            fieldNames.add(field);","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.java#L253-L289","documentation":"When the mapping.header property is 'true', the annotator derives header fields from each mapping file, and each mapping line must either omit header options (getting the implicit 'header=true') or explicitly set header=true. If a mapping line contains a header option set to something other than true, IllegalStateException is thrown because the two settings contradict each other.","triggerScenarios":"Setting mapping.header=true while a mapping file line (in the comma-separated mapping list) contains header=false or header=other-value, e.g. 'header=false, rules1.tab'.","commonSituations":"Mixing configs where the global header flag was switched to true but an old per-file 'header=false' remained; hand-editing mapping strings; combining mapping files with different header conventions.","solutions":["Remove 'header=false' (or any non-true header option) from the offending mapping line so the global header=true applies.","Set mapping.header=false and instead declare header fields explicitly via mapping.header.fieldnames if some files lack headers.","Make all mapping lines consistent: either all rely on global header=true or none carry header options.","Check the mappingLine named in the message to find exactly which entry conflicts."],"exampleFix":"// before\nprops.setProperty(\"tokensregexner.rules.mapping\", \"header=false, rules1.tab\");\nprops.setProperty(\"tokensregexner.rules.mapping.header\", \"true\");\n// after\nprops.setProperty(\"tokensregexner.rules.mapping\", \"rules1.tab\");\nprops.setProperty(\"tokensregexner.rules.mapping.header\", \"true\");","handlingStrategy":"validation","validationCode":"if (\"true\".equalsIgnoreCase(props.getProperty(\"tokensregexner.rules.mapping.header\",\"true\"))) {\n  for (String m : props.getProperty(\"tokensregexner.rules.mapping\",\"\").split(\",\"))\n    if (m.trim().matches(\".*header\\\\s*=\\\\s*(?!true\\\\b).*\")) throw new IllegalStateException(\"Conflicting header option in mapping: \" + m);\n}","typeGuard":"boolean mappingHeaderConflicts(String line) { return line != null && line.toLowerCase().contains(\"header\") && !java.util.regex.Pattern.compile(\"header\\\\s*=\\\\s*true\").matcher(line.toLowerCase()).find(); }","tryCatchPattern":"try { new TokensRegexNERAnnotator(name, props); } catch (IllegalStateException e) { if (e.getMessage().contains(\"header property is set to true\")) { log.error(\"Fix mapping line: \" + e.getMessage()); } throw e; }","preventionTips":["Keep header configuration in exactly one place (global flag or per-file, not both)","Lint mapping strings for stray header=false entries","Version-control annotator configs and review mapping edits carefully"],"tags":["java","ner","configuration","conflicting-options","corenlp"],"backgroundTag":"conflicting-config-options","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}