{"record":{"id":"1708e300576fe455","repo":"apache/iceberg","slug":"failed-to-list-tables-for-scope-s","errorCode":null,"errorMessage":"Failed to list tables for scope '%s'","messagePattern":"Failed to list tables for scope '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java","lineNumber":314,"sourceCode":"        // 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    }\n    tables.forEach(\n        table ->\n            Preconditions.checkState(\n                table.type() == SnowflakeIdentifier.Type.TABLE,\n                \"Expected TABLE, got identifier '%s' for scope '%s'\",\n                table,\n                scope));\n    return tables;\n  }\n\n  @Override\n  public SnowflakeTableMetadata loadTableMetadata(SnowflakeIdentifier tableIdentifier) {\n    Preconditions.checkArgument(","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java#L296-L332","documentation":"JdbcSnowflakeClient.listIcebergTables runs 'SHOW ICEBERG TABLES ... IN ACCOUNT/DATABASE/SCHEMA IDENTIFIER(?)' and converts SQLException into 'Failed to list tables for scope %s'. This means the SHOW ICEBERG TABLES statement failed on the Snowflake side - missing parent namespace, insufficient privileges, connection issues, or server error. Interrupted calls raise UncheckedInterruptedException instead.","triggerScenarios":"Calling listIcebergTables(scope) (e.g., SnowflakeCatalog.listTables) with a database or schema that doesn't exist or is inaccessible, wrong identifier casing, insufficient role privileges to show Iceberg tables, or a JDBC failure.","commonSituations":"Listing tables in a schema that was dropped; role without privileges on the parent database/schema; case-mismatched namespace names; transient Snowflake/network errors during Spark or Flink metadata queries.","solutions":["Confirm the database/schema path exists with exact casing (SHOW SCHEMAS IN DATABASE ...) before listing tables","Grant the role USAGE privileges on the parent database and schema","Catch NoSuchNamespaceException for expected missing scopes; inspect the IcebergException cause SQLException otherwise","Retry on transient errors and validate JDBC connectivity/auth configuration"],"exampleFix":"// before\ncatalog.listTables(Namespace.of(\"DB\", \"SCHEMA\")); // SQLException -> 'Failed to list tables'\n// after\ntry {\n  catalog.listTables(Namespace.of(\"DB\", \"SCHEMA\"));\n} catch (NoSuchNamespaceException e) {\n  // scope missing - create or correct the namespace\n} catch (IcebergException e) {\n  // check cause: privileges, auth, connectivity\n}","handlingStrategy":"try-catch","validationCode":"// verify the namespace path exists before listing tables\ncatalog.listNamespaces(Namespace.of(dbName));       // throws NoSuchNamespaceException if absent\ncatalog.listNamespaces(Namespace.of(dbName, schemaName));","typeGuard":null,"tryCatchPattern":"try {\n  catalog.listTables(Namespace.of(dbName, schemaName));\n} catch (NoSuchNamespaceException e) {\n  // missing scope: create it or return empty listing\n} catch (IcebergException e) {\n  SQLException cause = findCause(e, SQLException.class);\n  // classify via cause.getErrorCode(): privileges/auth vs transient; retry transient\n}","preventionTips":["Confirm database and schema exist with exact casing before listing tables","Grant role USAGE on parent database/schema","Handle NoSuchNamespaceException explicitly for optional scopes","Add backoff-based retries for transient Snowflake/network errors"],"tags":["snowflake","jdbc","table-listing"],"backgroundTag":"database-query-failed","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"}