Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-6536

Update from 4.5 to 5.0 fails when processing managed.json.patch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: OpenIDM 5.0.0
    • Fix Version/s: OpenIDM 5.0.0
    • Component/s: _Update
    • Labels:
    • Environment:
      OpenIDM version "5.0.0-SNAPSHOT" (revision: 0421867) using MySQL repo

      Description

      Steps to reproduce

      • install OpenIDM 4.5.0 with MySQL as a repo and start it
      • copy OpenIDM 5.0.0-SNAPSHOT ZIP in openidm/bin/update
      • launch Update:
        ./cli.sh update  --acceptLicense  --user openidm-admin:openidm-admin  --url http://localhost:8080/openidm openidm-5.0.0-SNAPSHOT.zip
        

      The update fails with this error found in the log:

      FINEST: processing archive file: conf/managed.json.patch
      Aug 31, 2016 11:17:26 AM org.forgerock.openidm.maintenance.upgrade.UpdateManagerImpl$UpdateThread run
      FINE: Failed to install update!
      org.forgerock.json.JsonException: String passed into parsing is not valid JSON
             	at org.forgerock.openidm.util.JsonUtil.parseStringified(JsonUtil.java:131)
             	at org.forgerock.openidm.maintenance.upgrade.UpdateManagerImpl$UpdateThread.applyConfigPatch(UpdateManagerImpl.java:1100)
             	at org.forgerock.openidm.maintenance.upgrade.UpdateManagerImpl$UpdateThread.run(UpdateManagerImpl.java:982)
      Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('r' (code 114)): was expecting comma to separate OBJECT entries
       at [Source: [
          {
              "operation" : "transform",
              "field" : "/objects",
              "value" : {
                  "script" : {
                      "type" : "text/javascript",
                      "source" : "require('managedPatchHelper').remove(content, 'user', 'schema.properties.lastSync.properties.effectiveAssignments.items').add(content, 'user', 'schema.properties.lastSync.properties.effectiveAssignments.items', '{\"type\":\"object\"}');"
                  }
              }
          },
          {
              "operation" : "transform",
              "field" : "/objects",
              "value" : {
                  "script" : {
                      "type" : "text/javascript",
                      "source" : "content.map(function (obj) { var schemaProps = obj.schema.properties; Object.keys(schemaProps).forEach(function (prop) { var propSchema = schemaProps[prop], withoutReauthPolicy; if (propSchema.policies) { withoutReauthPolicy = propSchema.policies.filter(function (p) { return p.policyId !== "re-auth-required"; }); if (propSchema.policies.length !== withoutReauthPolicy.length) { propSchema.isProtected = true; propSchema.policies = withoutReauthPolicy; } } }); return obj; })"
                  }
              }
          },
      ]
      ; line: 18, column: 322] 
      

      when looking at managed.json.patch, we see:

      [
          {
              "operation" : "transform",
              "field" : "/objects",
              "value" : {
                  "script" : {
                      "type" : "text/javascript",
                      "source" : "require('managedPatchHelper').remove(content, 'user', 'schema.properties.lastSync.properties.effectiveAssignments.items').add(content, 'user', 'schema.properties.lastSync.properties.effectiveAssignments.items', '{\"type\":\"object\"}');"
                  }
              }
          },
          {
              "operation" : "transform",
              "field" : "/objects",
              "value" : {
                  "script" : {
                      "type" : "text/javascript",
                      "source" : "content.map(function (obj) { var schemaProps = obj.schema.properties; Object.keys(schemaProps).forEach(function (prop) { var propSchema = schemaProps[prop], withoutReauthPolicy; if (propSchema.policies) { withoutReauthPolicy = propSchema.policies.filter(function (p) { return p.policyId !== "re-auth-required"; }); if (propSchema.policies.length !== withoutReauthPolicy.length) { propSchema.isProtected = true; propSchema.policies = withoutReauthPolicy; } } }); return obj; })"
                  }
              }
          },
      ]
      

      => I see at least 2 issues in this file
      1) the extra comma at the end
      2) the use of double quote in the second script ( !== "re-auth-required") that will conflict with the double quotes used in the JSON
      But even when I fix those 2 issues, the update still fails on this file with error:

      FINEST: processing archive file: conf/managed.json.patch
      Aug 31, 2016 11:28:17 AM org.forgerock.openidm.maintenance.upgrade.UpdateManagerImpl$UpdateThread run
      FINE: Failed to install update!
      org.forgerock.openidm.maintenance.upgrade.UpdateException: Patch request failed
             	at org.forgerock.openidm.maintenance.upgrade.UpdateManagerImpl$UpdateThread.patchConfig(UpdateManagerImpl.java:1258)
             	at org.forgerock.openidm.maintenance.upgrade.UpdateManagerImpl$UpdateThread.applyConfigPatch(UpdateManagerImpl.java:1100)
             	at org.forgerock.openidm.maintenance.upgrade.UpdateManagerImpl$UpdateThread.run(UpdateManagerImpl.java:982)
      Caused by: org.forgerock.json.resource.BadRequestException: Failed to eval script { "type": "text/javascript", "source": "require('managedPatchHelper').remove(content, 'user', 'schema.properties.lastSync.properties.effectiveAssignments.items').add(content, 'user', 'schema.properties.lastSync.properties.effectiveAssignments.items', '{\"type\":\"object\"}');" }     
      

      So this needs more analysis/fix/test while doing the resolution of this ticket

        Attachments

          Activity

            People

            Assignee:
            brmiller Brendan Miller
            Reporter:
            laurent.bristiel Laurent Bristiel [X] (Inactive)
            QA Assignee:
            Vojtěch Oczka Vojtěch Oczka
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: