Fix v38 table panel overrides migration when defaults.custom is missing (#112430)
Dashboard Migration: Fix v38 table panel overrides migration when defaults.custom is missing The v38 migration was incorrectly skipping field config overrides processing when fieldConfig.defaults.custom didn't exist. This caused custom.displayMode properties in overrides to not be migrated to the new custom.cellOptions format. The fix ensures migrateOverrides is always called for table panels, regardless of whether defaults.custom exists. Added comprehensive unit test covering this edge case to prevent regression. Issue discovered through comprehensive migration testing infrastructure.
This commit is contained in:
@@ -112,26 +112,22 @@ func processPanelsV38(panels []interface{}) {
|
||||
continue
|
||||
}
|
||||
|
||||
defaults, ok := fieldConfig["defaults"].(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
custom, ok := defaults["custom"].(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Migrate displayMode to cellOptions
|
||||
if displayMode, exists := custom["displayMode"]; exists {
|
||||
if displayModeStr, ok := displayMode.(string); ok {
|
||||
custom["cellOptions"] = migrateTableDisplayModeToCellOptions(displayModeStr)
|
||||
// Process defaults.custom if it exists
|
||||
if defaults, ok := fieldConfig["defaults"].(map[string]interface{}); ok {
|
||||
if custom, ok := defaults["custom"].(map[string]interface{}); ok {
|
||||
// Migrate displayMode to cellOptions in defaults
|
||||
if displayMode, exists := custom["displayMode"]; exists {
|
||||
if displayModeStr, ok := displayMode.(string); ok {
|
||||
custom["cellOptions"] = migrateTableDisplayModeToCellOptions(displayModeStr)
|
||||
}
|
||||
// Delete the legacy field
|
||||
delete(custom, "displayMode")
|
||||
}
|
||||
}
|
||||
// Delete the legacy field
|
||||
delete(custom, "displayMode")
|
||||
}
|
||||
|
||||
// Update any overrides referencing the cell display mode
|
||||
// This must be called regardless of whether defaults.custom exists
|
||||
migrateOverrides(fieldConfig)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user