@@ -227,7 +227,7 @@ func transformStateJSON(data []byte) ([]byte, error) {
227227func transformSnippetStateJSON (json string , instancePath string ) string {
228228 attrPath := instancePath + ".attributes"
229229 result := json
230-
230+
231231 // Set schema_version to 0 for v5
232232 result , _ = sjson .Set (result , instancePath + ".schema_version" , 0 )
233233
@@ -1513,6 +1513,66 @@ func transformZeroTrustAccessApplicationStateJSON(json string, path string) stri
15131513 json , _ = sjson .Set (json , attrPath + ".custom_pages" , customPages .Value ())
15141514 }
15151515
1516+ // Transform cors_headers from array format to object format
1517+ // In v4, cors_headers was stored as an array: [{"allowed_methods": [...], ...}]
1518+ // In v5, it should be a single object: {"allowed_methods": [...], ...}
1519+ corsHeaders := gjson .Get (json , attrPath + ".cors_headers" )
1520+ if corsHeaders .Exists () && corsHeaders .IsArray () {
1521+ corsArray := corsHeaders .Array ()
1522+ if len (corsArray ) > 0 && corsArray [0 ].Exists () {
1523+ // Take the first element and make it the object
1524+ json , _ = sjson .Set (json , attrPath + ".cors_headers" , corsArray [0 ].Value ())
1525+ } else {
1526+ // Empty array becomes null
1527+ json , _ = sjson .Set (json , attrPath + ".cors_headers" , nil )
1528+ }
1529+ }
1530+
1531+ // Transform landing_page_design from array format to object format
1532+ // In v4, landing_page_design was stored as an array: [{"title": "...", "message": "...", ...}]
1533+ // In v5, it should be a single object: {"title": "...", "message": "...", ...}
1534+ landingPageDesign := gjson .Get (json , attrPath + ".landing_page_design" )
1535+ if landingPageDesign .Exists () && landingPageDesign .IsArray () {
1536+ landingArray := landingPageDesign .Array ()
1537+ if len (landingArray ) > 0 && landingArray [0 ].Exists () {
1538+ // Take the first element and make it the object
1539+ json , _ = sjson .Set (json , attrPath + ".landing_page_design" , landingArray [0 ].Value ())
1540+ } else {
1541+ // Empty array becomes null
1542+ json , _ = sjson .Set (json , attrPath + ".landing_page_design" , nil )
1543+ }
1544+ }
1545+
1546+ // Transform saas_app from array format to object format
1547+ // In v4, saas_app was stored as an array: [{"consumer_service_url": "...", "sp_entity_id": "...", ...}]
1548+ // In v5, it should be a single object: {"consumer_service_url": "...", "sp_entity_id": "...", ...}
1549+ saasApp := gjson .Get (json , attrPath + ".saas_app" )
1550+ if saasApp .Exists () && saasApp .IsArray () {
1551+ saasArray := saasApp .Array ()
1552+ if len (saasArray ) > 0 && saasArray [0 ].Exists () {
1553+ // Take the first element and make it the object
1554+ json , _ = sjson .Set (json , attrPath + ".saas_app" , saasArray [0 ].Value ())
1555+ } else {
1556+ // Empty array becomes null
1557+ json , _ = sjson .Set (json , attrPath + ".saas_app" , nil )
1558+ }
1559+ }
1560+
1561+ // Transform scim_config from array format to object format
1562+ // In v4, scim_config was stored as an array: [{"enabled": true, "remote_uri": "...", ...}]
1563+ // In v5, it should be a single object: {"enabled": true, "remote_uri": "...", ...}
1564+ scimConfig := gjson .Get (json , attrPath + ".scim_config" )
1565+ if scimConfig .Exists () && scimConfig .IsArray () {
1566+ scimArray := scimConfig .Array ()
1567+ if len (scimArray ) > 0 && scimArray [0 ].Exists () {
1568+ // Take the first element and make it the object
1569+ json , _ = sjson .Set (json , attrPath + ".scim_config" , scimArray [0 ].Value ())
1570+ } else {
1571+ // Empty array becomes null
1572+ json , _ = sjson .Set (json , attrPath + ".scim_config" , nil )
1573+ }
1574+ }
1575+
15161576 // Transform policies from simple string list to complex object list
15171577 policies := gjson .Get (json , attrPath + ".policies" )
15181578 if policies .IsArray () {
0 commit comments