Skip to content

fix(oxidize): add defensive check for missing co_changes table #68

@nicabarnimble

Description

@nicabarnimble

Problem

oxidize crashes with no such table: co_changes when git history data isn't available. This happens when:

  • scrape git was never run
  • Shallow clone detected and skipped
  • New repo with insufficient commit history

Current Behavior

// temporal.rs:29 - crashes if table missing
conn.prepare("SELECT file_a, file_b, count FROM co_changes ...")?;
Error: no such table: co_changes

Proposed Fix

Add table existence check before querying:

// In oxidize, before querying co_changes:
let table_exists: bool = conn.query_row(
    "SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE type='table' AND name='co_changes')",
    [],
    |row| row.get(0)
)?;

if !table_exists {
    println!("⚠️  Skipping temporal projection (no git history data)");
    return Ok(vec![]); // Skip gracefully instead of crash
}

Additional Edge Cases to Handle

Case Current Proposed
Table missing Crash Skip with warning
Table empty Bail Skip with warning
Few co-changes (count < 2) Bail Skip with warning
All single-file commits Empty pairs, bail Skip with warning

Context

Discovered in PR #67 when CI failed due to shallow clone. Fixed CI with fetch-depth: 0, but oxidize should be resilient regardless of git history availability.

Labels

  • enhancement
  • good first issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions