fix: harden model catalog projections
This commit is contained in:
@@ -119,9 +119,10 @@ func Run(request Request) error {
|
||||
if !filepath.IsAbs(request.InstallationPath) || filepath.Base(request.InstallationPath) != "thothii-installation.yaml" {
|
||||
return errors.New("installation migration requires an absolute thothii-installation.yaml path")
|
||||
}
|
||||
if !filepath.IsAbs(request.OutputPath) || filepath.Base(request.OutputPath) != "thothii-installation.yaml" ||
|
||||
outputExtension := strings.ToLower(filepath.Ext(request.OutputPath))
|
||||
if !filepath.IsAbs(request.OutputPath) || outputExtension != ".yaml" && outputExtension != ".yml" ||
|
||||
filepath.Clean(request.OutputPath) == filepath.Clean(request.InstallationPath) {
|
||||
return errors.New("installation migration output must be a different absolute thothii-installation.yaml path")
|
||||
return errors.New("installation migration output must be a different absolute YAML path")
|
||||
}
|
||||
if request.SessionDefault == "" || request.EmbeddingID == "" || request.EmbeddingDimensions <= 0 {
|
||||
return errors.New("installation migration requires session default, embedding id, and positive embedding dimensions")
|
||||
|
||||
@@ -69,6 +69,19 @@ func TestRunReportsProviderAuthenticationConflictAndPublishesNothing(t *testing.
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunAcceptsVersionedYAMLCandidateFilename(t *testing.T) {
|
||||
fixture := migrationFixture(t, false)
|
||||
request := fixture.request()
|
||||
request.OutputPath = filepath.Join(filepath.Dir(request.OutputPath), "thothii-installation.v2.yaml")
|
||||
|
||||
if err := Run(request); err != nil {
|
||||
t.Fatalf("Run() error = %v", err)
|
||||
}
|
||||
if info, err := os.Stat(request.OutputPath); err != nil || !info.Mode().IsRegular() {
|
||||
t.Fatalf("versioned candidate: info=%v err=%v", info, err)
|
||||
}
|
||||
}
|
||||
|
||||
type migrationTestFixture struct {
|
||||
legacy string
|
||||
output string
|
||||
|
||||
Reference in New Issue
Block a user