{"record":{"id":"77b36612bf89de52","repo":"apache/iceberg","slug":"unsupported-scope-type-for-listschemas-s","errorCode":null,"errorMessage":"Unsupported scope type for listSchemas: %s","messagePattern":"Unsupported scope type for listSchemas: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java","lineNumber":251,"sourceCode":"    return databases;\n  }\n\n  @Override\n  public List<SnowflakeIdentifier> listSchemas(SnowflakeIdentifier scope) {\n    StringBuilder baseQuery = new StringBuilder(\"SHOW SCHEMAS\");\n    String[] queryParams = null;\n    switch (scope.type()) {\n      case ROOT:\n        // account-level listing\n        baseQuery.append(\" IN ACCOUNT\");\n        break;\n      case DATABASE:\n        // database-level listing\n        baseQuery.append(\" IN DATABASE IDENTIFIER(?)\");\n        queryParams = new String[] {scope.toIdentifierString()};\n        break;\n      default:\n        throw new IllegalArgumentException(\n            String.format(\"Unsupported scope type for listSchemas: %s\", scope));\n    }\n\n    final String finalQuery = baseQuery.toString();\n    final String[] finalQueryParams = queryParams;\n    List<SnowflakeIdentifier> schemas;\n    try {\n      schemas =\n          connectionPool.run(\n              conn ->\n                  queryHarness.query(\n                      conn, finalQuery, SCHEMA_RESULT_SET_HANDLER, finalQueryParams));\n    } catch (SQLException e) {\n      throw snowflakeExceptionToIcebergException(\n          scope, e, String.format(\"Failed to list schemas for scope '%s'\", scope));\n    } catch (InterruptedException e) {\n      throw new UncheckedInterruptedException(\n          e, \"Interrupted while listing schemas for scope '%s'\", scope);","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java#L233-L269","documentation":"JdbcSnowflakeClient.listSchemas only supports scoping the listing at ACCOUNT or DATABASE level; any other SnowflakeIdentifier.Type passed as scope triggers an IllegalArgumentException. It is an input-validation guard on the scope argument, thrown before any SQL is executed.","triggerScenarios":"Calling listSchemas with a scope identifier whose type is neither ACCOUNT/ROOT nor DATABASE — e.g. passing a SCHEMA- or TABLE-typed SnowflakeIdentifier to SnowflakeCatalog.listNamespaces with an invalid hierarchy.","commonSituations":"Bug in caller code building SnowflakeIdentifier scopes, mixing up schema vs database identifiers when listing nested namespaces, or generic catalog adapters passing the wrong identifier level.","solutions":["Pass SnowflakeIdentifier.ofRoot() (account scope) or a DATABASE-typed identifier to listSchemas","Fix the caller so nested-namespace listing resolves the scope to the database level before calling","Inspect the scope object's type() before invoking and route unsupported cases to a different API","Add tests for namespace listing at each hierarchy level to catch scope-type mistakes early"],"exampleFix":"// before\nclient.listSchemas(SnowflakeIdentifier.ofSchema(\"db\", \"sc\")); // throws\n// after\nclient.listSchemas(SnowflakeIdentifier.ofDatabase(\"db\")); // or SnowflakeIdentifier.ofRoot()","handlingStrategy":"validation","validationCode":"SnowflakeIdentifier.Type t = scope.type();\nif (t != SnowflakeIdentifier.Type.ROOT && t != SnowflakeIdentifier.Type.DATABASE) {\n  throw new IllegalArgumentException(\"listSchemas requires ROOT or DATABASE scope, got: \" + t);\n}","typeGuard":"static boolean isSchemaListableScope(SnowflakeIdentifier s) {\n  SnowflakeIdentifier.Type t = s.type();\n  return t == SnowflakeIdentifier.Type.ROOT || t == SnowflakeIdentifier.Type.DATABASE;\n}","tryCatchPattern":"try {\n  client.listSchemas(scope);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Bad scope for listSchemas: {}\", scope);\n  throw e;\n}","preventionTips":["Validate SnowflakeIdentifier.type() before invoking scope-sensitive client methods","Map namespace hierarchy levels to the correct identifier types in catalog adapters","Write unit tests for listing at each scope level","Prefer factory methods (ofRoot/ofDatabase/ofSchema) over raw constructors to avoid mistyped identifiers"],"tags":["snowflake","invalid-argument","scope"],"backgroundTag":"invalid-argument-value","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"}