{"record":{"id":"e4f957c074fbe32c","repo":"stanfordnlp/CoreNLP","slug":"unknown-value-s-in-s","errorCode":null,"errorMessage":"unknown value \"%s\" in %s","messagePattern":"unknown value \"(.+?)\" in (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/Timex.java","lineNumber":564,"sourceCode":"    if (Pattern.matches(\"\\\\d\\\\d\\\\d\\\\dW\\\\d+\", this.val)) {\n      int year = Integer.parseInt(this.val.substring(0, 4));\n      int week = Integer.parseInt(this.val.substring(5));\n      int startDay = (week - 1) * 7;\n      int endDay = startDay + 6;\n      Calendar start = makeCalendar(year, startDay);\n      Calendar end = makeCalendar(year, endDay);\n      return new Pair<>(start, end);\n    }\n\n    // PRESENT_REF\n    if (this.val.equals(\"PRESENT_REF\")) {\n      Calendar rc = documentTime.getDate();  // todo: This case doesn't check for documentTime being null and will NPE\n      Calendar start = copyCalendar(rc);\n      Calendar end = copyCalendar(rc);\n      return new Pair<>(start, end);\n    }\n\n    throw new RuntimeException(String.format(\"unknown value \\\"%s\\\" in %s\", this.val, this));\n  }\n\n  private static Calendar makeCalendar(int year, int month, int day) {\n    Calendar date = Calendar.getInstance();\n    date.clear();\n    date.set(year, month - 1, day, 0, 0, 0);\n    return date;\n  }\n\n  private static Calendar makeCalendar(int year, int dayOfYear) {\n    Calendar date = Calendar.getInstance();\n    date.clear();\n    date.set(Calendar.YEAR, year);\n    date.set(Calendar.DAY_OF_YEAR, dayOfYear);\n    return date;\n  }\n\n  private static Calendar copyCalendar(Calendar c) {","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/Timex.java#L546-L582","documentation":"Terminal fallthrough of Timex.getRange: if the val matched none of the recognized forms (dates, PnY/PnM/PnD durations, seasons, quarters, empty-set, etc.), the method throws RuntimeException with the unrecognized val. It signals a value format the range expander does not understand.","triggerScenarios":"Calling getRange() on vals like 'P1W' (weeks are not handled), 'P1YT2H', '20090602T1200' style oddities, or other unnormalized strings that reach the end of the method.","commonSituations":"TimeML corpora containing ISO 8601 week durations (PnW) or compound durations that this implementation does not expand; feeding raw ISO 8601 strings into Timex.","solutions":["Convert week durations (PnW) to days (PnD) before building/using the Timex","Normalize compound durations into the supported PnY/PnM/PnD forms","Catch RuntimeException, log the val, and return null or an empty range","Extend getRange with an additional Pattern case for the unsupported format"],"exampleFix":"// before\nPair<Calendar,Calendar> range = timex.getRange(documentTime);\n// after\nString v = timex.val();\nif (v != null && v.matches(\"P\\\\d+W\")) {\n  timex = new Timex(v.replaceFirst(\"(P\\\\d+)W\", \"$1\") /* convert weeks to days: P1W -> P7D */);\n}\nPair<Calendar,Calendar> range = timex.getRange(documentTime);","handlingStrategy":"try-catch","validationCode":"Set<String> supported = Pattern: date8, P\\\\d+[YMD], \\\\d+SP, quarter/season codes — pre-check val against these;","typeGuard":null,"tryCatchPattern":"try { range = timex.getRange(docTime); } catch (RuntimeException e) { log.warn(\"unhandled Timex val: \" + timex.val()); range = null; }","preventionTips":["Normalize ISO 8601 durations (weeks, compound forms) to PnY/PnM/PnD before building Timex","Keep a whitelist of supported val shapes in your pipeline","Always pass a non-null documentTime to avoid both NPE and fallthrough"],"tags":["java","timex","unsupported-format"],"backgroundTag":"unsupported-operation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}