fix(providers): saving a key for an enabled source tries the gaps again (#8102)

A source that needs a key, such as Last.fm, answers "not found" without
one, and the enricher settles each row it tried that way at the current
version. Switching Last.fm on before entering its key settled every gap
without it, and saving the key didn't move the version, so Last.fm never
came back to them. The sources signature now marks each enabled source
that has a key, so a key arriving or leaving moves the version. Replacing
one key with another still doesn't.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 23:50:29 -05:00
co-authored by Claude Opus 5.5
parent 3a7081be19
commit f3997b657c
5 changed files with 115 additions and 56 deletions
+7 -2
View File
@@ -93,7 +93,7 @@ func TestSettingsService_UpdateProvider_FlippingEnabledBumpsVersion(t *testing.T
}
}
func TestSettingsService_UpdateProvider_KeyOnlyDoesNotBumpVersion(t *testing.T) {
func TestSettingsService_UpdateProvider_ReplacingAKeyDoesNotBumpVersion(t *testing.T) {
pool := dbtest.Pool(t)
resetRegistryForTests()
defer resetRegistryForTests()
@@ -105,6 +105,11 @@ func TestSettingsService_UpdateProvider_KeyOnlyDoesNotBumpVersion(t *testing.T)
t.Fatal(err)
}
// The first key moves the version: the source searched without one.
firstKey := "first1"
if bumped, err := s.UpdateProvider(context.Background(), "fake-album", ProviderUpdatePatch{APIKey: &firstKey}); err != nil || !bumped {
t.Fatalf("first key: bumped=%v err=%v, want true nil", bumped, err)
}
startVersion := s.CurrentVersion()
newKey := "abc123"
@@ -113,7 +118,7 @@ func TestSettingsService_UpdateProvider_KeyOnlyDoesNotBumpVersion(t *testing.T)
t.Fatalf("UpdateProvider: %v", err)
}
if bumped {
t.Error("versionBumped = true, want false for key-only change")
t.Error("versionBumped = true, want false for a replaced key")
}
if s.CurrentVersion() != startVersion {
t.Errorf("CurrentVersion changed: %d → %d, want unchanged", startVersion, s.CurrentVersion())