{"record":{"id":"6f1ee3da1e8acc01","repo":"apache/iceberg","slug":"invalid-namespace-s-6f1ee3","errorCode":null,"errorMessage":"Invalid namespace: %s","messagePattern":"Invalid namespace: (.+?)","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":404,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":370,"sourceCode":"        throw new UncheckedIOException(\n            String.format(\"Cannot drop namespace '%s': %s\", namespace, e.getMessage()), e);\n      }\n    } catch (NessieNotFoundException e) {\n      LOG.error(\n          \"Cannot drop namespace '{}': ref '{}' is no longer valid.\",\n          namespace,\n          getRef().getName(),\n          e);\n    } catch (BaseNessieClientServerException e) {\n      throw new UncheckedIOException(\n          String.format(\"Cannot drop namespace '%s': %s\", namespace, e.getMessage()), e);\n    }\n    return false;\n  }\n\n  private static void checkNamespaceIsValid(Namespace namespace) {\n    if (namespace.isEmpty()) {\n      throw new NoSuchNamespaceException(\"Invalid namespace: %s\", namespace);\n    }\n  }\n\n  public Map<String, String> loadNamespaceMetadata(Namespace namespace)\n      throws NoSuchNamespaceException {\n    checkNamespaceIsValid(namespace);\n\n    ContentKey key = ContentKey.of(namespace.levels());\n    try {\n      Map<ContentKey, Content> contentMap = withReference(api.getContent()).key(key).get();\n      return unwrapNamespace(contentMap.get(key))\n          .orElseThrow(\n              () -> new NoSuchNamespaceException(\"Namespace does not exist: %s\", namespace))\n          .getProperties();\n    } catch (NessieNotFoundException e) {\n      throw new UncheckedIOException(\n          String.format(\n              \"Cannot load namespace '%s': ref '%s' is no longer valid.\",","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L352-L388","documentation":"checkNamespaceIsValid rejects an empty Namespace (zero levels). createNamespace, dropNamespace, loadNamespaceMetadata and updateProperties all require a concrete multi-level identifier, so passing Namespace.of() (or the root) throws NoSuchNamespaceException 'Invalid namespace'. Nessie namespaces map to content keys, which must have at least one element.","triggerScenarios":"Calling createNamespace/loadNamespaceMetadata/dropNamespace/setProperties/removeProperties with Namespace.root() or Namespace.of() — e.g. code paths that fall back to an empty namespace when configuration is missing.","commonSituations":"Config property for target namespace left blank; splitting an empty string; generic catalog tooling that passes the root namespace through to a Nessie catalog.","solutions":["Ensure the caller supplies at least one namespace level before invoking the catalog operation.","Fix the configuration that yields an empty namespace (e.g. warehouse/namespace property).","Guard with namespaceExists/isEmpty checks in application code before calling."],"exampleFix":"// before\nNamespace ns = Namespace.of(cfg.get(\"namespace\", \"\")); // empty -> Invalid namespace\ncatalog.createNamespace(ns);\n// after\nString[] levels = cfg.getOrDefault(\"namespace\", \"\").split(\"\\\\.\");\nPreconditions.checkArgument(levels.length > 0 && !levels[0].isEmpty(), \"namespace required\");\ncatalog.createNamespace(Namespace.of(levels));","handlingStrategy":"validation","validationCode":"if (namespace == null || namespace.isEmpty()) {\n  throw new IllegalArgumentException(\"Namespace must have at least one level\");\n}\ncatalog.createNamespace(namespace);","typeGuard":"static boolean isValidNamespace(Namespace ns) {\n  return ns != null && !ns.isEmpty() && ns.levels().length > 0;\n}","tryCatchPattern":"try {\n  catalog.loadNamespaceMetadata(ns);\n} catch (NoSuchNamespaceException e) {\n  if (e.getMessage().contains(\"Invalid namespace\")) {\n    throw new IllegalArgumentException(\"Caller passed an empty namespace\", e);\n  }\n  throw e;\n}","preventionTips":["Never pass Namespace.root() to Nessie catalog namespace APIs.","Validate configuration-supplied namespace strings are non-empty and split correctly.","Add a shared guard helper wrapping all Nessie namespace mutations."],"tags":["nessie","namespace","validation","empty-argument"],"backgroundTag":"empty-required-field","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"}