{"record":{"id":"8dcba962d5ad2899","repo":"stanfordnlp/CoreNLP","slug":"parsing-ssurgeon-args-unknown-flag-argskey","errorCode":null,"errorMessage":"Parsing Ssurgeon args: unknown flag ${argsKey}","messagePattern":"Parsing Ssurgeon args: unknown flag (.+?)","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java","lineNumber":582,"sourceCode":"        case POSITION_ARG:\n          argsBox.position = argsValue;\n          break;\n        case UPDATE_MORPHO_FEATURES:\n        case UPDATE_MORPHO_FEATURES_LOWER:\n          argsBox.updateMorphoFeatures = argsValue;\n          break;\n        case REMOVE:\n          argsBox.remove.add(argsValue);\n          break;\n        case REMOVE_MORPHO_FEATURES:\n        case REMOVE_MORPHO_FEATURES_LOWER:\n          argsBox.removeMorphoFeatures.add(argsValue);\n          break;\n        default:\n          String key = argsKey.substring(1);\n          Class<? extends CoreAnnotation<?>> annotation = AnnotationLookup.toCoreKey(key);\n          if (annotation == null) {\n            throw new SsurgeonParseException(\"Parsing Ssurgeon args: unknown flag \" + argsKey);\n          }\n          argsBox.annotations.put(key, argsValue);\n      }\n    }\n    return argsBox;\n  }\n\n  /**\n   * Given a string entry, converts it into a SsurgeonEdit object.\n   */\n  public static SsurgeonEdit parseEditLine(String editLine, Map<String, String> attributeArgs, Language language) {\n    try {\n      // Extract the operation name first\n      final String[] tuples1 = editLine.split(\"\\\\s+\", 2);\n      if (tuples1.length < 1) {\n        throw new SsurgeonParseException(\"Error in SsurgeonEdit.parseEditLine: invalid number of arguments\");\n      }\n      final String command = tuples1[0];","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java#L564-L600","documentation":"parseArgsBox maps '-flag value' pairs to SsurgeonArgs fields. For flags that are not one of the known built-in ones, the flag text (minus leading '-') is looked up via AnnotationLookup.toCoreKey as a CoreAnnotations key; if it is not a valid core key, SsurgeonParseException is thrown with the unknown flag name.","triggerScenarios":"An edit line containing a flag like -myflag or -lemna (typo of -lemma) that matches no known Ssurgeon flag and is also not resolvable to a CoreAnnotation key via AnnotationLookup.toCoreKey.","commonSituations":"Typos in flag names (-node vs -nodes, -reln vs -rel); using flags from an older/newer CoreNLP version where the flag list changed; inventing flags expecting them to be ignored; passing annotation keys that don't exist in AnnotationLookup.","solutions":["Check the flag spelling against the Ssurgeon documentation for that edit type (e.g. -node, -nodes, -reln, -lemma).","If you intended a CoreAnnotation, use a key name that AnnotationLookup.toCoreKey recognizes (e.g. -pos, -lemma, -ner).","Remove flags not supported by your CoreNLP version; check the changelog for renamed flags.","Catch SsurgeonParseException at rule-load time and log the whole edit line to spot the bad flag."],"exampleFix":"// before\neditnode -node node -rel sndep:obj\n// after\neditnode -node node -reln nsubj","handlingStrategy":"validation","validationCode":"Set<String> known = Set.of(\"-node\",\"-nodes\",\"-reln\",\"-gov\",\"-dep\",\"-edge\",\"-lemma\",\"-pos\",\"-ner\",\"-value\",\"-position\",\"-weight\");\nfor (String flag : flags) {\n  if (!known.contains(flag) && AnnotationLookup.toCoreKey(flag.substring(1)) == null)\n    throw new IllegalArgumentException(\"Unknown ssurgeon flag: \" + flag);\n}","typeGuard":null,"tryCatchPattern":"try { SsurgeonEdit.parseEditLine(line, attrs, language); } catch (SsurgeonParseException e) { if (e.getMessage().startsWith(\"Parsing Ssurgeon args\")) log.error(\"Unknown flag, check spelling: \" + e.getMessage()); }","preventionTips":["Copy flag names from the official Ssurgeon documentation for the exact CoreNLP version","Check AnnotationLookup.toCoreKey for any annotation-style flag you use","Pin the CoreNLP version so flag sets don't drift"],"tags":["parsing","ssurgeon","unknown-flag","cli"],"backgroundTag":"invalid-flag-value","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"}