{"record":{"id":"7e2382d9c73bbd1b","repo":"apache/iceberg","slug":"database-properties-should-not-contain-key-comme-7e2382","errorCode":null,"errorMessage":"Database properties should not contain key: 'comment'.","messagePattern":"Database properties should not contain key: 'comment'\\.","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java","lineNumber":240,"sourceCode":"      throws DatabaseAlreadyExistException, CatalogException {\n    if (asNamespaceCatalog != null) {\n      try {\n        asNamespaceCatalog.createNamespace(appendLevel(baseNamespace, databaseName), metadata);\n      } catch (AlreadyExistsException e) {\n        if (!ignoreIfExists) {\n          throw new DatabaseAlreadyExistException(getName(), databaseName, e);\n        }\n      }\n    } else {\n      throw new UnsupportedOperationException(\n          \"Namespaces are not supported by catalog: \" + getName());\n    }\n  }\n\n  private Map<String, String> mergeComment(Map<String, String> metadata, String comment) {\n    Map<String, String> ret = Maps.newHashMap(metadata);\n    if (metadata.containsKey(\"comment\")) {\n      throw new CatalogException(\"Database properties should not contain key: 'comment'.\");\n    }\n\n    if (!StringUtils.isNullOrWhitespaceOnly(comment)) {\n      ret.put(\"comment\", comment);\n    }\n    return ret;\n  }\n\n  @Override\n  public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade)\n      throws DatabaseNotExistException, DatabaseNotEmptyException, CatalogException {\n    if (asNamespaceCatalog != null) {\n      try {\n        boolean success = asNamespaceCatalog.dropNamespace(appendLevel(baseNamespace, name));\n        if (!success && !ignoreIfNotExists) {\n          throw new DatabaseNotExistException(getName(), name);\n        }\n      } catch (NoSuchNamespaceException e) {","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java#L222-L258","documentation":"FlinkCatalog.mergeComment validates that user-supplied database metadata does not already reserve the 'comment' key, because the comment string is stored separately and merged into properties as 'comment'. Supplying 'comment' inside the metadata map would conflict, so a CatalogException is thrown.","triggerScenarios":"Calling createDatabase (or newProperties paths) with a metadata map containing key 'comment' while also (or instead) using the dedicated comment parameter — the map and the explicit comment field collide.","commonSituations":"Scripts that copy raw namespace properties from an existing database (which include 'comment') back into createDatabase; generic property maps built from config files that happen to define 'comment'.","solutions":["Remove the 'comment' key from the metadata map and pass the description via the dedicated comment parameter.","Strip reserved keys before calling: metadata.remove(\"comment\") when copying properties from an existing database.","If the comment text came from the map, extract it and pass it as the comment argument instead.","Validate input property maps against reserved keys in your own tooling before invoking the catalog."],"exampleFix":"// before\nMap<String, String> meta = old.getMetadata(); // contains \"comment\"\ncatalog.createDatabase(\"db\", meta, old.getComment(), false);\n// after\nMap<String, String> meta = new HashMap<>(old.getMetadata());\nString comment = meta.remove(\"comment\");\ncatalog.createDatabase(\"db\", meta, comment != null ? comment : old.getComment(), false);","handlingStrategy":"validation","validationCode":"// strip reserved keys from metadata before createDatabase\nstatic Map<String, String> sanitize(Map<String, String> meta) {\n  Map<String, String> copy = new HashMap<>(meta);\n  if (copy.containsKey(\"comment\")) {\n    throw new IllegalArgumentException(\"pass 'comment' via the comment parameter, not metadata\");\n  }\n  return copy;\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.createDatabase(name, metadata, comment, ignoreIfExists);\n} catch (CatalogException e) {\n  if (e.getMessage().contains(\"should not contain key: 'comment'\")) {\n    Map<String, String> fixed = new HashMap<>(metadata);\n    String c = fixed.remove(\"comment\");\n    catalog.createDatabase(name, fixed, c != null ? c : comment, ignoreIfExists);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Treat 'comment' as a reserved key in all database property maps","When copying properties from an existing database, extract comment first (as getDatabase does)","Add an input-validation helper that rejects reserved keys before catalog calls"],"tags":["flink","catalog","reserved-key"],"backgroundTag":"invalid-config-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}