Common problems → causes → solutions.
Error: "401 Unauthorized"
Cause: Token missing R2 Data Catalog permissions.
Solution: Use "Admin Read & Write" token (includes catalog + storage permissions). Test with catalog.list_namespaces().
Error: "403 Forbidden" on data files
Cause: Token lacks storage permissions.
Solution: Token needs both R2 Data Catalog + R2 Storage Bucket Item permissions.
Error: New token fails after rotation.
Solution: Create new token → test in staging → update prod → monitor 24h → revoke old.
Error: "404 Catalog not found"
Cause: Catalog not enabled or wrong URI.
Solution: Run wrangler r2 bucket catalog enable <bucket>. URI must be HTTPS with /iceberg/ and case-sensitive bucket name.
Error: Cannot create/load tables.
Cause: Warehouse ≠ bucket name.
Solution: Set warehouse="bucket-name" to match bucket exactly.
Error: "TableAlreadyExistsError"
Solution: Use try/except to load existing or check first.
Error: Cannot create table.
Solution: Create namespace first: catalog.create_namespace("ns")
Error: "422 Validation" on schema update.
Cause: Incompatible change (required field, type shrink).
Solution: Only add nullable columns, compatible type widening (int→long, float→double).
Error: Scan returns no data.
Cause: Incorrect filter or partition column.
Solution: Test without filter first: table.scan().to_pandas(). Verify partition column names.
Error: Performance degrades over time.
Cause: Too many small files.
Solution: Check file count, compact if >1000 or avg <10MB. See api.md.
Error: "Cannot cast" on append.
Cause: PyArrow types don't match Iceberg schema.
Solution: Cast to int64 (Iceberg default), not int32. Check table.schema().
Problem: File count unchanged or compaction takes hours.
Cause: Target size too large, or table too big for PyIceberg.
Solution: Only compact if avg <50MB. For >1TB tables, use Spark. Run during low-traffic periods.
Problem: Expiration fails or orphan cleanup deletes active data.
Cause: Too aggressive retention or wrong order.
Solution: Always expire snapshots first with retain_last=10, then cleanup orphans with 3+ day threshold.
Problem: CommitFailedException with multiple writers.
Cause: Optimistic locking - simultaneous commits.
Solution: Add retry with exponential backoff (see patterns.md).
Problem: Old schema/data after external update.
Cause: Cached metadata.
Solution: Reload table: table = catalog.load_table(("ns", "table"))
Scans: Use row_filter and selected_fields to reduce data scanned.
Partitions: 100-1000 optimal. Avoid high cardinality (millions) or low (<10).
**Files:** Keep 100-500MB avg. Compact if <10MB or >10k files.
| Resource | Recommended | Impact if Exceeded |
|---|---|---|
| Tables/namespace | <10k | Slow list ops |
| Files/table | <100k | Slow query planning |
| Partitions/table | 100-1k | Metadata overhead |
| Snapshots/table | Expire >7d | Metadata bloat |
| Error Message | Likely Cause | Fix |
|---|---|---|
401 Unauthorized |
Missing/invalid token | Check token has catalog+storage permissions |
403 Forbidden |
Token lacks storage permissions | Add R2 Storage Bucket Item permission |
404 Not Found |
Catalog not enabled or wrong URI | Run wrangler r2 bucket catalog enable |
409 Conflict |
Table/namespace already exists | Use try/except or load existing |
422 Unprocessable Entity |
Schema validation failed | Check type compatibility, required fields |
CommitFailedException |
Concurrent write conflict | Add retry logic with backoff |
NamespaceAlreadyExistsError |
Namespace exists | Use try/except or load existing |
NoSuchTableError |
Table doesn't exist | Check namespace+table name, create first |
TypeError: Cannot cast |
PyArrow type mismatch | Cast data to match Iceberg schema |
When things go wrong, check in order:
npx wrangler r2 bucket catalog status <bucket>catalog.list_namespaces() succeeds/iceberg/, correct bucket namecreate_table()logging.basicConfig(level=logging.DEBUG)pip install --upgrade pyiceberg (≥0.5.0)import logging
logging.basicConfig(level=logging.DEBUG)
# Now operations show HTTP requests/responses