{"record":{"id":"41439fdaf4598877","repo":"apache/iceberg","slug":"unsupported-scope-type-for-listicebergtables-s","errorCode":null,"errorMessage":"Unsupported scope type for listIcebergTables: %s","messagePattern":"Unsupported scope type for listIcebergTables: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java","lineNumber":301,"sourceCode":"    StringBuilder baseQuery = new StringBuilder(\"SHOW ICEBERG TABLES\");\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      case SCHEMA:\n        // schema-level listing\n        baseQuery.append(\" IN SCHEMA IDENTIFIER(?)\");\n        queryParams = new String[] {scope.toIdentifierString()};\n        break;\n      default:\n        throw new IllegalArgumentException(\n            String.format(\"Unsupported scope type for listIcebergTables: %s\", scope));\n    }\n\n    final String finalQuery = baseQuery.toString();\n    final String[] finalQueryParams = queryParams;\n    List<SnowflakeIdentifier> tables;\n    try {\n      tables =\n          connectionPool.run(\n              conn ->\n                  queryHarness.query(conn, finalQuery, TABLE_RESULT_SET_HANDLER, finalQueryParams));\n    } catch (SQLException e) {\n      throw snowflakeExceptionToIcebergException(\n          scope, e, String.format(\"Failed to list tables for scope '%s'\", scope));\n    } catch (InterruptedException e) {\n      throw new UncheckedInterruptedException(\n          e, \"Interrupted while listing tables for scope '%s'\", scope);\n    }","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java#L283-L319","documentation":"JdbcSnowflakeClient.listIcebergTables supports listing Iceberg tables only at ACCOUNT or SCHEMA scope; any other SnowflakeIdentifier.Type triggers an IllegalArgumentException before SQL execution. This is argument validation guarding the scope hierarchy expected by the listing API.","triggerScenarios":"Calling listIcebergTables with a scope typed DATABASE, TABLE, or COLUMN instead of ACCOUNT/ROOT or SCHEMA — e.g. passing a database-level identifier where the API expects a schema, or a generic adapter forwarding an unresolvable namespace.","commonSituations":"Caller confusion between Iceberg namespace levels and Snowflake identifier types, catalog adapters that map arbitrary namespace lengths to Snowflake scopes, or refactoring that changed expected hierarchy depth.","solutions":["Pass a SCHEMA-typed SnowflakeIdentifier (SnowflakeIdentifier.ofSchema(db, schema)) or the account root to listIcebergTables","Correct the namespace-to-identifier mapping in the calling code before invoking the client","Validate scope.type() at the call site and choose the proper listing method per level","Add unit tests covering listing at each supported scope type"],"exampleFix":"// before\nclient.listIcebergTables(SnowflakeIdentifier.ofDatabase(\"db\")); // throws\n// after\nclient.listIcebergTables(SnowflakeIdentifier.ofSchema(\"db\", \"my_schema\"));","handlingStrategy":"validation","validationCode":"SnowflakeIdentifier.Type t = scope.type();\nif (t != SnowflakeIdentifier.Type.ROOT && t != SnowflakeIdentifier.Type.SCHEMA) {\n  throw new IllegalArgumentException(\"listIcebergTables requires ROOT or SCHEMA scope, got: \" + t);\n}","typeGuard":"static boolean isTableListableScope(SnowflakeIdentifier s) {\n  SnowflakeIdentifier.Type t = s.type();\n  return t == SnowflakeIdentifier.Type.ROOT || t == SnowflakeIdentifier.Type.SCHEMA;\n}","tryCatchPattern":"try {\n  client.listIcebergTables(scope);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Bad scope for listIcebergTables: {}\", scope);\n  throw e;\n}","preventionTips":["Check scope.type() before calling listIcebergTables","Use SnowflakeIdentifier.ofSchema(db, schema) to build table-listing scopes","Add adapter tests ensuring namespace length maps to correct scope type","Document the supported scope hierarchy (ROOT/SCHEMA) in your catalog wrapper"],"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"}