Stop calling the PostgreSQL store SQLite, and stop guessing where it is
Two things that were only ever confusing, and one of them stopped a command working on the cluster. The store type was named SQLite and kept the name when PostgreSQL was added, so OpenPostgres returned a *SQLite and all seventy-odd methods on the production store were spelled after the database it was not running on. Nothing broke; people did. Earlier today I added three methods to *SQLite for a table that on this cluster only ever lives in PostgreSQL, and the name did not once look wrong. It is a field, which is all it ever was. `llmgw users` and `llmgw keys` defaulted --store to a SQLite path. On a deployment whose store is PostgreSQL every one of them failed with "unable to open database file" while the right answer sat in auth.store in the config file beside them; the conclusion an operator draws is that the tool is broken, and they are not far off. They now ask the server's own configuration before falling back, and the error names which of the three sources chose the address — the failure was never the path, it was which one picked it. The single-machine default still applies last, so a deployment with no config file keeps working with no flags. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3febb6ef63
commit
ebce41e22d
32 files changed
+320
-140
No files matched your search
@@ -57,7 +57,7 @@ func authConfig(path string) func(*config.Server) {
|
||||
|
||||
func enableThreads(t *testing.T, path string, hours int) {
|
||||
t.Helper()
|
||||
withStore(t, path, func(s *store.SQLite) {
|
||||
withStore(t, path, func(s *store.DB) {
|
||||
if err := s.SetThreadRetention(context.Background(), "proj", hours); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func enableThreads(t *testing.T, path string, hours int) {
|
||||
func storedTurns(t *testing.T, path, thread string) []store.Message {
|
||||
t.Helper()
|
||||
var out []store.Message
|
||||
withStore(t, path, func(s *store.SQLite) {
|
||||
withStore(t, path, func(s *store.DB) {
|
||||
msgs, err := s.Thread(context.Background(), "proj", thread)
|
||||
if err != nil {
|
||||
t.Fatalf("reading thread %q: %v", thread, err)
|
||||
@@ -164,7 +164,7 @@ func TestOneProjectCannotReadAnothersThread(t *testing.T) {
|
||||
enableThreads(t, path, 24)
|
||||
|
||||
// A key in a second project.
|
||||
withStore(t, path, func(s *store.SQLite) {
|
||||
withStore(t, path, func(s *store.DB) {
|
||||
if err := s.PutProject(context.Background(),
|
||||
store.Project{ID: "other", TeamID: "team", Name: "Other"}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -211,7 +211,7 @@ func TestWithoutAThreadNothingIsStoredAtAll(t *testing.T) {
|
||||
t.Fatalf("%d %s", code, msg)
|
||||
}
|
||||
|
||||
withStore(t, path, func(s *store.SQLite) {
|
||||
withStore(t, path, func(s *store.DB) {
|
||||
// Pruning with a cutoff far past every retention window deletes every
|
||||
// thread there is, so a count of zero means none were created.
|
||||
n, err := s.PruneThreads(context.Background(), time.Now().Add(1000*time.Hour))
|
||||
@@ -258,7 +258,7 @@ func TestSomeoneCanUnsayWhatTheySaid(t *testing.T) {
|
||||
if code := h.forget(t, key, "th1"); code != http.StatusNoContent {
|
||||
t.Fatalf("deleting the thread returned %d", code)
|
||||
}
|
||||
withStore(t, path, func(s *store.SQLite) {
|
||||
withStore(t, path, func(s *store.DB) {
|
||||
if _, err := s.Thread(context.Background(), "proj", "th1"); err == nil {
|
||||
t.Error("the conversation survived being deleted")
|
||||
}
|
||||
@@ -272,7 +272,7 @@ func TestDeletingSomeoneElsesThreadLooksLikeDeletingNothing(t *testing.T) {
|
||||
path, mint := provision(t)
|
||||
mine := mint(t, "mine")
|
||||
enableThreads(t, path, 24)
|
||||
withStore(t, path, func(s *store.SQLite) {
|
||||
withStore(t, path, func(s *store.DB) {
|
||||
if err := s.PutProject(context.Background(),
|
||||
store.Project{ID: "other", TeamID: "team", Name: "Other"}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in new issue
Block a user