Fix: Improve staleness check error handling (bd-2q6d, bd-o4qy, bd-n4td)
Changes: - CheckStaleness now returns errors for corrupted last_import_time metadata instead of silently returning false (bd-o4qy) - Added handling for empty string metadata (memory store behavior) - Enhanced warning messages when staleness check fails to be more explicit that operation continues with potentially stale data (bd-n4td) - Added test coverage for corrupted metadata scenario Closes bd-2q6d, bd-o4qy, bd-n4td 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -343,6 +343,30 @@ func TestCheckStaleness_NewerJSONL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckStaleness_CorruptedMetadata(t *testing.T) {
|
||||
store := memory.New("")
|
||||
ctx := context.Background()
|
||||
|
||||
tmpDir, err := os.MkdirTemp("", "bd-stale-test-*")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
dbPath := filepath.Join(tmpDir, "bd.db")
|
||||
|
||||
// Set invalid timestamp format
|
||||
store.SetMetadata(ctx, "last_import_time", "not-a-valid-timestamp")
|
||||
|
||||
_, err = CheckStaleness(ctx, store, dbPath)
|
||||
if err == nil {
|
||||
t.Error("Expected error for corrupted metadata, got nil")
|
||||
}
|
||||
if err != nil && !strings.Contains(err.Error(), "corrupted last_import_time") {
|
||||
t.Errorf("Expected 'corrupted last_import_time' error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckForMergeConflicts(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user