Repository: syncthing/syncthing (language: go)

Issue:
Posting config with invalid versioner type causes panic
Presumably it would be better to reject the configuration instead of crashing.

```
Panic at 2023-09-15T09:20:34+02:00
panic: creating versioner: requested versioning type "!@#!@(#*" does not exist

goroutine 343 [running]:
github.com/syncthing/syncthing/lib/model.(*model).addAndStartFolderLockedWithIgnores(_, {{0x140003cb860, 0x7}, {0x0, 0x0}, 0x1, {0x140003cb868, 0x2}, 0x0, {0x14001494960, ...}, ...}, ...)
        github.com/syncthing/syncthing/lib/model/model.go:420 +0xaa4
github.com/syncthing/syncthing/lib/model.(*model).addAndStartFolderLocked(_, {{0x140003cb860, 0x7}, {0x0, 0x0}, 0x1, {0x140003cb868, 0x2}, 0x0, {0x14001494960, ...}, ...}, ...)
        github.com/syncthing/syncthing/lib/model/model.go:353 +0x1a8
github.com/syncthing/syncthing/lib/model.(*model).restartFolder(_, {{0x140003ca5d8, 0x7}, {0x0, 0x0}, 0x1, {0x140003ca5e8, 0x2}, 0x0, {0x140014948c0, ...}, ...}, ...)
        github.com/syncthing/syncthing/lib/model/model.go:562 +0x440
github.com/syncthing/syncthing/lib/model.(*model).CommitConfiguration(_, {0x25, {0x14001b18ea0, 0x1, 0x1}, {0x140014978c0, 0x2, 0x2}, {0x1, {0x140003cafd0, ...}, ...}, ...}, ...)
        github.com/syncthing/syncthing/lib/model/model.go:3030 +0xa6c
github.com/syncthing/syncthing/lib/config.(*wrapper).notifyListener(_, {_, _}, {0x25, {0x14001b18ea0, 0x1, 0x1}, {0x140014978c0, 0x2, 0x2}, ...}, ...)
        github.com/syncthing/syncthing/lib/config/wrapper.go:343 +0x10c
github.com/syncthing/syncthing/lib/config.(*wrapper).notifyListeners.func1({0x1030ce978?, 0x1400019c180?})
        github.com/syncthing/syncthing/lib/config/wrapper.go:334 +0x88
created by github.com/syncthing/syncthing/lib/config.(*wrapper).notifyListeners in goroutine 53
        github.com/syncthing/syncthing/lib/config/wrapper.go:333 +0x130
```


Discussion / hints:
@calmh Hey! 
Is someone working on this? I would like to contribute, if you could tell me more about the issue?

Fix patch:
diff --git a/lib/model/model.go b/lib/model/model.go
index 970d84c4566..c8007f61dcd 100644
--- a/lib/model/model.go
+++ b/lib/model/model.go
@@ -2976,6 +2976,16 @@ func (*model) VerifyConfiguration(from, to config.Configuration) error {
 			return errors.New("folder type must not be changed from/to receive-encrypted")
 		}
 	}
+
+	// Verify that any requested versioning is possible to construct, or we
+	// will panic later when starting the folder.
+	for _, to := range to.Folders {
+		if to.Versioning.Type != "" {
+			if _, err := versioner.New(to); err != nil {
+				return err
+			}
+		}
+	}
 	return nil
 }
 


Test patch: