Skip to main content
This guide covers common issues you may encounter when using Basecut, along with their solutions and debugging techniques.

Database Connection Issues

Connection Refused

Symptoms:
✗ Error: failed to connect to database
  dial tcp: connection refused
Solutions:
  1. Verify database is running:
    pg_isready -h localhost -p 5432
    
  2. Check connection string format:
    # Correct format
    postgresql://user:password@host:5432/database
    
    # Common mistakes
    postgresql://host:5432  # Missing database name
    postgresql://user@host  # Missing port
    
  3. Test connectivity:
    psql "$BASECUT_DATABASE_URL" -c "SELECT 1"
    
  4. Check firewall rules:
    • Ensure port 5432 is open
    • For self-hosted agents, verify network security groups allow outbound connections

Host Not Found

Symptoms:
✗ Error: failed to connect to database
  dial tcp: lookup prod-db.internal: no such host
Solutions:
  1. Verify hostname resolves:
    nslookup prod-db.internal
    dig prod-db.internal
    
  2. Use IP address instead:
    postgresql://user:pass@10.0.1.100:5432/myapp
    
  3. For private databases without public access:
    • Use local execution (default) instead of agent execution
    • Or deploy self-hosted agents in the same VPC

Permission Denied

Symptoms:
✗ Error: permission denied for schema public
✗ Error: must be owner of table users
Solutions:
  1. Grant SELECT permissions:
    GRANT USAGE ON SCHEMA public TO basecut_user;
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO basecut_user;
    
    -- For future tables
    ALTER DEFAULT PRIVILEGES IN SCHEMA public
      GRANT SELECT ON TABLES TO basecut_user;
    
  2. Verify user permissions:
    -- Check what schemas user can access
    SELECT schema_name
    FROM information_schema.schemata
    WHERE schema_name NOT LIKE 'pg_%' AND schema_name != 'information_schema';
    
    -- Check table permissions
    SELECT table_schema, table_name, privilege_type
    FROM information_schema.table_privileges
    WHERE grantee = 'basecut_user';
    

SSL/TLS Connection Errors

Symptoms:
✗ Error: SSL is not enabled on the server
✗ Error: certificate verify failed
Solutions:
  1. For databases requiring SSL:
    postgresql://user:pass@host:5432/db?sslmode=require
    
  2. For self-signed certificates:
    postgresql://user:pass@host:5432/db?sslmode=require&sslrootcert=/path/to/ca.crt
    
  3. Disable SSL verification (dev only, not recommended for production):
    postgresql://user:pass@host:5432/db?sslmode=disable
    

Authentication Failures

Invalid API Key

Symptoms:
✗ Error: Unauthorized: invalid API key
✗ Error: API key is invalid or expired
Solutions:
  1. Verify API key is set:
    echo $BASECUT_API_KEY
    
  2. Re-authenticate:
    basecut login
    
  3. Check API key format:
    • Live keys: bc_live_*
    • Test keys: bc_test_*
    • Ensure no extra spaces or newlines
  4. For CI/CD, verify secret is correctly set:
    # GitHub Actions
    echo "${{ secrets.BASECUT_API_KEY }}" | wc -c  # Should be > 50
    
    # GitLab CI
    echo "$BASECUT_API_KEY" | wc -c
    
  5. Check API key in dashboard:
    • Login to basecut.dev
    • Navigate to Settings → API Keys
    • Verify key hasn’t been revoked

whoami Command Fails

Symptoms:
$ basecut whoami
not authenticated
Solutions:
  1. Login again:
    basecut login
    
  2. Check credentials file:
    cat ~/.basecut/credentials
    # Should contain API key
    
  3. Use the profile you logged into:
    basecut whoami --profile staging
    

Snapshot Creation Issues

Extraction Limits Reached

Symptoms:
⚠ Warning: per_table limit (1000) reached for table 'users'
⚠ Warning: total row limit (50000) reached
✓ Snapshot created with partial data
Solutions:
  1. Increase limits in basecut.yml:
    limits:
      rows:
        per_table: 5000 # Increase per-table limit
        total: 200000 # Increase total budget
    
  2. Add more specific WHERE clauses:
    from:
      - table: users
        where: 'created_at > :since AND status = :status'
        params:
          since: '2024-01-01'
          status: 'active' # More specific filter
    
  3. Use table-specific limits:
    limits:
      rows:
        per_table: 1000
        tables:
          public.audit_logs: 100 # Limit noisy tables
          public.sessions: 0 # Unlimited for this table (use `exclude` to skip)
    

Foreign Key Constraint Violations

Symptoms:
✗ Error: foreign key constraint violation
  Table 'orders' references missing row in 'users'
Solutions:
  1. This shouldn’t happen! Basecut automatically ensures referential integrity. If you see this:
  2. Workaround - increase upstream depth:
    traverse:
      parents: 15 # Follow parent relationships further
      children: 10
    

Timeout on Large Extractions

Symptoms:
✗ Error: context deadline exceeded
✗ Error: operation timed out after 300s
Solutions:
  1. Use self-hosted agents instead of local execution:
    # Instead of local execution (default)
    basecut snapshot create --config basecut.yml
    
    # Use agent execution for large datasets
    basecut snapshot create --config basecut.yml --async
    
  2. Reduce snapshot scope:
    limits:
      rows:
        per_table: 1000 # Start smaller
    
  3. Use sampling:
    sampling:
      mode: 'first' # Faster than 'random'
    

Snapshot Restore Issues

Schema Validation Failures

Symptoms:
✗ Error: schema mismatch: table 'users' missing column 'email_verified'
✗ Error: snapshot schema version incompatible with target database
Solutions:
  1. Run migrations first:
    # Run migrations to match snapshot schema
    npm run migrate
    
    # Then restore
    basecut snapshot restore dev-seed:latest --target "$BASECUT_DATABASE_URL"
    
  2. Force restore (skip validation):
    basecut snapshot restore dev-seed:latest --target "$BASECUT_DATABASE_URL" --force
    
    Only use --force if you understand the schema differences. Missing columns or type changes can still fail during insert.
  3. Inspect the exact snapshot reference you’re restoring:
    basecut snapshot inspect dev-seed:latest --json
    

Duplicate Key Violations

Symptoms:
✗ Error: duplicate key value violates unique constraint "users_pkey"
  Key (id)=(123) already exists
Solutions:
  1. Use —reset flag to truncate tables first:
    basecut snapshot restore dev-seed:latest \
      --target "$BASECUT_DATABASE_URL" \
      --reset
    
    --reset is destructive. It truncates all tables included in the snapshot before restoring.
  2. Manually truncate conflicting tables:
    TRUNCATE TABLE users, orders, line_items CASCADE;
    
  3. Restore to empty database:
    # Create fresh database
    createdb myapp_test
    
    # Restore snapshot
    basecut snapshot restore dev-seed:latest \
      --target "postgresql://localhost:5432/myapp_test"
    

Restore Too Slow

Symptoms:
  • Restore takes several minutes for small snapshots
  • Progress bar stuck at 0%
Solutions:
  1. Check database connectivity:
    ping -c 3 your-db-host
    
  2. Use local database for faster restore:
    # Instead of remote database
    basecut snapshot restore dev-seed:latest --target "postgresql://remote:5432/db"
    
    # Use local database
    basecut snapshot restore dev-seed:latest --target "postgresql://localhost:5432/db"
    
  3. Disable triggers during restore (advanced):
    ALTER TABLE users DISABLE TRIGGER ALL;
    -- Restore snapshot
    ALTER TABLE users ENABLE TRIGGER ALL;
    

Storage Issues

S3 Access Denied

Symptoms:
✗ Error: failed to upload snapshot
  AccessDenied: User does not have PutObject permission
Solutions:
  1. Verify AWS credentials:
    aws s3 ls s3://your-bucket/
    
  2. Check IAM policy grants s3:PutObject, s3:GetObject, and s3:ListBucket on your bucket. See Storage Providers for the full policy.
  3. Use correct credentials:
    export AWS_ACCESS_KEY_ID=your_key_id
    export AWS_SECRET_ACCESS_KEY=your_secret_key
    
    # Or use AWS CLI profile
    aws configure
    

S3 Region/Endpoint Errors (Common with --async)

Symptoms:
✗ Error: failed to upload snapshot
  ... Invalid region ...
Why this happens:
  • Local runs can succeed using your local AWS profile region
  • --async runs execute on a self-hosted agent, which may not have the same region config
Solutions:
  1. Set region in basecut.yml for S3 output:
    output:
      provider: s3
      bucket: your-bucket
      region: us-east-1
    
  2. For Cloudflare R2 / S3-compatible endpoints, set both endpoint and region:
    output:
      provider: s3
      bucket: your-r2-bucket
      region: auto
      endpoint: https://<accountid>.r2.cloudflarestorage.com
    
  3. If you cannot set output.region, ensure AWS_REGION is set on the agent environment.

GCS Permission Errors

Symptoms:
✗ Error: failed to upload to GCS
  403: Forbidden
Solutions:
  1. Verify GCS credentials:
    gsutil ls gs://your-bucket/
    
  2. Check service account permissions:
    gcloud storage buckets add-iam-policy-binding gs://your-bucket \
      --member=serviceAccount:basecut@project.iam.gserviceaccount.com \
      --role=roles/storage.objectAdmin
    
  3. Use correct credentials:
    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
    
    # Or use gcloud auth
    gcloud auth application-default login
    

Snapshot Not Found

Symptoms:
✗ Error: snapshot not found: dev-seed:latest
✗ Error: no versions found for snapshot 'dev-seed'
Solutions:
  1. List available snapshots:
    basecut snapshot list --name dev-seed
    
  2. Check snapshot name spelling:
    # Common mistake: wrong name
    basecut snapshot restore dev-seed:latest  # Wrong
    basecut snapshot restore dev-data:latest  # Correct
    
  3. Verify storage provider configuration:
    # In basecut.yml
    output:
      provider: s3
      bucket: your-bucket # Ensure this matches where snapshot was created
      region: us-east-1
    

Self-Hosted Agent Issues

Agent Not Picking Up Jobs

Symptoms:
  • Jobs submitted with --async never complete
  • Agent logs show no activity
Solutions:
  1. Check agent logs:
    docker logs basecut-agent
    
  2. Verify API key format and org access:
    echo "$BASECUT_API_KEY" | grep -E '^bc_(live|test)_'
    
  3. Check network connectivity to Basecut API:
    docker exec basecut-agent curl https://api.basecut.dev/health
    
  4. Verify agent registration:
    • Check dashboard for registered agents
    • Ensure agent is in “Active” state

Agent Database Connection Failures

Symptoms:
Agent log: failed to connect to database
Agent log: dial tcp: i/o timeout
Solutions:
  1. Test database access from agent:
    docker exec basecut-agent psql "$BASECUT_DATABASE_URL" -c "SELECT 1"
    
  2. Check network security groups:
    • Verify agent’s security group allows outbound to database port
    • Verify database’s security group allows inbound from agent
  3. Use private IP for database in same VPC:
    # Instead of public IP
    postgresql://user:pass@1.2.3.4:5432/db
    
    # Use private IP
    postgresql://user:pass@10.0.1.100:5432/db
    

Performance Issues

Slow Extractions

Symptoms:
  • Snapshot creation takes hours
  • “Extracting…” stuck at same table count
Solutions:
  1. Check database indexes:
    -- Ensure foreign key columns are indexed
    CREATE INDEX CONCURRENTLY idx_orders_user_id ON orders(user_id);
    CREATE INDEX CONCURRENTLY idx_line_items_order_id ON line_items(order_id);
    
  2. Use sampling instead of full extraction:
    sampling:
      mode: 'first' # Much faster than 'random'
    
  3. Reduce traversal depth:
    traverse:
      parents: 3 # Reduce from 10
      children: 5 # Reduce from 10
    
  4. Use agent execution for large datasets:
    basecut snapshot create --config basecut.yml --async
    

Debugging Techniques

Check Configuration Parsing

Verify YAML syntax:
# Use a YAML validator
python -c "import yaml; yaml.safe_load(open('basecut.yml'))"

Test Individual Components

Test database connection:
psql "$BASECUT_DATABASE_URL" -c "SELECT current_database(), current_user;"
Test storage access:
# S3
aws s3 cp test.txt s3://your-bucket/test.txt

# GCS
echo "test" | gsutil cp - gs://your-bucket/test.txt

# Local
touch /path/to/snapshots/test.txt

Getting Help

If you’ve tried the solutions above and still have issues:
  1. Check the logs:
    • Agent: docker logs basecut-agent
  2. File a GitHub issue:
  3. Contact support:

Next Steps