You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/config-versioning.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,16 @@ PicoClaw uses a schema versioning system for `config.json` to ensure smooth upgr
20
20
- V0 configs now migrate directly to CurrentVersion (V2) instead of going through V1
21
21
-`makeBackup()` now uses date-only suffix (e.g., `config.json.20260330.bak`) and also backs up `.security.yml`
22
22
23
+
### Version 3
24
+
-**Introduction**: Enhanced type safety and improved error handling
25
+
-**Changes**:
26
+
- Added comma-ok type assertions in channel configuration decoding to prevent potential panics
27
+
- Improved error logging for Weixin channel configuration decoding
28
+
- Enhanced security configuration documentation and examples
29
+
-**Auto-migration**: V2 configs are automatically migrated to V3 on load with no user action required
30
+
-**Backup**: Before migration, the system creates a date-stamped backup (e.g., `config.json.20260413.bak`) in the same directory
31
+
-**Downgrade risk**: Once migrated to V3, the config cannot be safely loaded by older V2-only versions. To downgrade, restore from the auto-created backup file.
7.**Test Thoroughly**: Test with real user config files
165
175
8.**Update Defaults**: Keep `defaults.go` in sync with the latest schema
166
176
177
+
## V2→V3 Migration Guide
178
+
179
+
### What Changed?
180
+
181
+
Version 3 introduces improved type safety and error handling:
182
+
183
+
-**Type-safe channel decoding**: All channel type assertions now use comma-ok pattern (`val, ok := v.(*Settings)`) to prevent panics if Type and Settings are mismatched
184
+
-**Enhanced error logging**: Weixin channel now logs errors on `GetDecoded()` failure for consistency with other channels
185
+
-**Documentation fixes**: Corrected stray quotes in JSON configuration examples
186
+
187
+
### Auto-Migration Behavior
188
+
189
+
When you run PicoClaw with a V2 config file:
190
+
191
+
1.**Detection**: PicoClaw reads the `version` field and detects V2
192
+
2.**Backup**: Before any changes, creates `config.json.YYYYMMDD.bak` (e.g., `config.json.20260413.bak`)
193
+
3.**Migration**: Applies V2→V3 structural changes (primarily internal type safety improvements)
194
+
4.**Save**: Writes the updated config with `"version": 3`
195
+
5.**Continue**: Starts normally with the V3 config
196
+
197
+
**No user action required** — the migration happens automatically on first load.
198
+
199
+
### Backup Location
200
+
201
+
Backups are created in the same directory as your config file:
cp ~/.picoclaw/.security.yml.20260413.bak ~/.picoclaw/.security.yml # if it exists
218
+
```
219
+
3. Use a PicoClaw version that supports V2 configs
220
+
221
+
**Alternative**: Manually edit `config.json` and change `"version": 3` to `"version": 2`. This works because V3 changes are primarily code-level safety improvements, not structural schema changes.
222
+
167
223
## Example Migration
168
224
169
225
### Scenario: Adding a new field with default value
0 commit comments