{"record":{"id":"4579e841d4cfd283","repo":"apache/iceberg","slug":"content-type-of-from-identifier-s-should-be-of-s","errorCode":null,"errorMessage":"content type of from identifier %s should be of %s","messagePattern":"content type of from identifier (.+?) should be of (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":541,"sourceCode":"        throw new AlreadyExistsException(\n            \"Cannot rename %s to %s. Another content of type %s with same name already exists\",\n            from, to, existingToContent.getType());\n      }\n    }\n  }\n\n  private static void validateFromContentForRename(\n      TableIdentifier from, Content.Type type, IcebergContent existingFromContent) {\n    if (existingFromContent == null) {\n      if (type == Content.Type.ICEBERG_VIEW) {\n        throw new NoSuchViewException(\"View does not exist: %s\", from);\n      } else if (type == Content.Type.ICEBERG_TABLE) {\n        throw new NoSuchTableException(\"Table does not exist: %s\", from);\n      } else {\n        throw new RuntimeException(\"Cannot perform rename for content type: \" + type);\n      }\n    } else if (existingFromContent.getType() != type) {\n      throw new RuntimeException(\n          String.format(\"content type of from identifier %s should be of %s\", from, type));\n    }\n  }\n\n  public boolean dropTable(TableIdentifier identifier, boolean purge) {\n    return dropContent(identifier, purge, Content.Type.ICEBERG_TABLE);\n  }\n\n  public boolean dropView(TableIdentifier identifier, boolean purge) {\n    return dropContent(identifier, purge, Content.Type.ICEBERG_VIEW);\n  }\n\n  private boolean dropContent(TableIdentifier identifier, boolean purge, Content.Type type) {\n    getRef().checkMutable();\n\n    IcebergContent existingContent = fetchContent(identifier);\n    if (existingContent == null) {\n      return false;","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L523-L559","documentation":"Thrown by validateFromContentForRename when the content found under the from identifier exists but is of a different type than requested (e.g. an IcebergTable found while a view rename was requested). The rename is aborted before any Nessie commit. Message includes the identifier and the expected type.","triggerScenarios":"Calling renameView(from, to) where from is actually a table, or renameTable where from is a view; also when the same path has different content on a different ref than assumed.","commonSituations":"A table was replaced by a view (or vice versa) under the same name; developer assumed view but the name refers to a table; branch checked out shows different content type.","solutions":["Check the actual content type: use catalog.tableExists vs catalog.viewExists before renaming.","Call the matching rename API (renameTable for tables, renameView for views).","If the content type changed intentionally, drop/recreate or rename with the correct API."],"exampleFix":"// before\ncatalog.renameView(TableIdentifier.of(\"ns\", \"summary\"), TableIdentifier.of(\"ns\", \"summary_v2\")); // summary is a table\n// after\nTableIdentifier from = TableIdentifier.of(\"ns\", \"summary\");\nif (catalog.tableExists(from)) {\n  catalog.renameTable(from, TableIdentifier.of(\"ns\", \"summary_v2\"));\n} else if (catalog.viewExists(from)) {\n  catalog.renameView(from, TableIdentifier.of(\"ns\", \"summary_v2\"));\n}","handlingStrategy":"validation","validationCode":"boolean isTable = catalog.tableExists(from); boolean isView = catalog.viewExists(from); if (!isTable && !isView) throw ...; ","typeGuard":null,"tryCatchPattern":"try { catalog.renameView(from, to); } catch (RuntimeException e) { if (e.getMessage().contains(\"should be of\")) { /* wrong content type; pick matching API */ } }","preventionTips":["Dispatch on tableExists/viewExists instead of hardcoding the rename API","Avoid reusing names across tables and views","Confirm content type on the exact ref used at runtime"],"tags":["nessie","rename","type-mismatch","catalog"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}