{"record":{"id":"0a2e4f1b20dba805","repo":"stanfordnlp/CoreNLP","slug":"input-array-with-0-rows","errorCode":null,"errorMessage":"Input array with 0 rows","messagePattern":"Input array with 0 rows","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/neural/ConvertModels.java","lineNumber":80,"sourceCode":"      }\n    }\n\n    return out;\n  }\n\n  public static List<List<List<Double>>> fromTensor(SimpleTensor in) {\n    List<List<List<Double>>> out = new ArrayList<>();\n\n    for (int i = 0; i < in.numSlices(); ++i) {\n      out.add(fromMatrix(in.getSlice(i)));\n    }\n\n    return out;\n  }\n\n  public static SimpleMatrix toMatrix(List<List<Double>> in) {\n    if (in.size() == 0) {\n      throw new IllegalArgumentException(\"Input array with 0 rows\");\n    }\n    if (in.get(0).size() == 0) {\n      throw new IllegalArgumentException(\"Input array with 0 columns\");\n    }\n    for (int i = 1; i < in.size(); ++i) {\n      if (in.get(i).size() != in.get(0).size()) {\n        throw new IllegalArgumentException(\"Input array with uneven columns\");\n      }\n    }\n\n    SimpleMatrix out = new SimpleMatrix(in.size(), in.get(0).size());\n    for (int i = 0; i < in.size(); ++i) {\n      List<Double> row = in.get(i);\n      for (int j = 0; j < row.size(); ++j) {\n        out.set(i, j, row.get(j));\n      }\n    }\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/neural/ConvertModels.java#L62-L98","documentation":"ConvertModels.toMatrix converts a List<List<Double>> into a SimpleMatrix but rejects empty input: calling it with a list containing zero rows throws IllegalArgumentException('Input array with 0 rows'). The neural model conversion code requires at least one row to infer matrix dimensions.","triggerScenarios":"Calling toMatrix with an empty List (in.size()==0), typically via toTensor, f, antecedentMatrix, anaphorMatrix, pairFeaturesMatrix, or pairwiseFirstLayerBias when a model file yields no feature rows.","commonSituations":"Converting an empty/corrupt serialized model (e.g. empty word-vector or sentiment model file) during legacy-to-new model conversion, or a preprocessing step that filtered out all entries.","solutions":["Check the input list is non-empty before calling toMatrix","Verify the source model file is not empty or corrupt","Regenerate the feature lists so at least one row is produced"],"exampleFix":"// before\nSimpleMatrix m = ConvertModels.toMatrix(rows); // rows may be empty\n// after\nif (rows.isEmpty()) { throw new IllegalStateException(\"no rows to convert\"); }\nSimpleMatrix m = ConvertModels.toMatrix(rows);","handlingStrategy":"validation","validationCode":"if (rows == null || rows.isEmpty()) {\n  throw new IllegalArgumentException(\"toMatrix requires at least one row\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  SimpleMatrix m = ConvertModels.toMatrix(rows);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"0 rows\")) {\n    logger.warning(\"empty model features; skipping conversion\");\n    return;\n  }\n  throw e;\n}","preventionTips":["Check list size before converting model feature tables","Validate serialized model files are non-empty before conversion","Fail fast in feature extraction if zero entries are produced"],"tags":["matrix","validation","neural","empty-input"],"backgroundTag":"empty-required-field","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"}