UUID required value


#1

Enonic version: 7.3
OS: MAC

Hi,
I am experiencing an error i never encountered before. It happen when i try to create. a new node. The error message say so: “Value of type [java.lang.String] cannot be converted to [Reference]: UUID cannot be blank”
The object i send to create API is:

  "parentPath": "/myapp/mypath",
  "contentType": "no.app.appname:insurance-claim",
  "data": {
    "insurance": "a8104997-9c9e-4055-870d-761aa334db00",
    "date": "2020-06-18",
    "description": "My description",
    "attachments": [],
    "isFixable": {
      "_selected": "yes",
      "yes": {
        "priceEstimate": 0
      }
    },
    "repairAttachment": ""
  },
  "name": "SM-a8104997-9c9e-4055-870d-761aa334db00",
  "displayName": "SM-a8104997-9c9e-4055-870d-761aa334db00",
  "requireValid": false

anyone have encountered this issue ?

best regards
carlo


#2

Well, the first logical step here would be to try and find the field(s) which cause the error. There are only a few fields that are mandatory for create operation: parentPath, contentType and data. So try to create a node only with those and then start adding the rest of the fields until you get the error. Let us know which field that was.


#3

Hi!
Can you please check if one of those fields is a getter or other kind of function?
You can check that by printing you object this way:

JSON.stringify(objWithFunction, function(key, val) {
  if (typeof val === 'function') {
    return val.toString();
  }
  return val;
}, 2);

#4

Thanks both for answers. I checked and there are no functions in the object i send to “create”. The fields where reside the errors seems to be the attachments , they are required in order to save the content but in the content-type both are not required:

<input name="attachments" type="MediaSelector">
      <label i18n="insuranceClaim.attachments">Attachments</label>
      <occurrences minimum="0" maximum="0"/>
    </input> 

<input name="repairAttachment" type="MediaSelector">
      <label i18n="insuranceClaim.repairAttachment">Attachments</label>
      <occurrences minimum="0" maximum="1"/>
    </input>

I was aspecting this configuration would save the content anyway with or without attachment files :slight_smile:


#5

Can you post the entire content type schema?


#7

here is the whole schema:

<content-type>
  <display-name i18n="insuranceClaim.displayName">Insurance claim</display-name>
  <description i18n="insuranceClaim.typeDescription">Instrument insurance claim</description>
  <super-type>base:structured</super-type>

  <form>
    <field-set>
      <label i18n="insuranceClaim.claim">Claim</label>
      <items>
        <input name="insurance" type="ContentSelector">
          <label i18n="insuranceClaim.insurance">Insurance</label>
          <occurrences minimum="1" maximum="1"/>
          <config>
            <allowContentType>insurance</allowContentType>
          </config>
        </input>

        <input name="date" type="Date">
          <label i18n="insuranceClaim.date">Date</label>
          <occurrences minimum="1" maximum="1"/>
        </input>

        <input name="description" type="TextArea">
          <label i18n="insuranceClaim.description">Description</label>
          <occurrences minimum="0" maximum="1"/>
        </input>

        <input name="attachments" type="MediaSelector">
          <label i18n="insuranceClaim.attachments">Attachments</label>
          <occurrences minimum="0" maximum="0"/>
        </input>
      </items>
    </field-set>

    <field-set>
      <label i18n="insuranceClaim.repair">Repair</label>
      <items>
        <option-set name="isFixable">
          <label i18n="insuranceClaim.isFixable">Is the damage fixable</label>
          <occurrences minimum="1" maximum="1"/>

          <options minimum="1" maximum="1">
            <option name="yes">
              <label i18n="insuranceClaim.isFixableYes">Yes</label>
              <items>
                <input  name="priceEstimate" type="Long">
                  <label i18n="insuranceClaim.priceEstimate">Price estimate for repair</label>
                </input>
              </items>
            </option>
            <option name="no">
              <label i18n="insuranceClaim.isFixableNo">No</label>
            </option>
          </options>
        </option-set>
        <input name="repairAttachment" type="MediaSelector">
          <label i18n="insuranceClaim.repairAttachment">Attachments</label>
          <occurrences minimum="0" maximum="1"/>
        </input>
      </items>
    </field-set>
  </form>
</content-type>

#8

We found out the problem do not reside on the schema but in how Enonic want the empty attachments to be set in case do not exists. In the code we set attachments as empty array, [], and reapirAttachemnt as empty string, ‘’, (since accept only one file), if no file exists. By changing both to “undefined” instead we got rid of the error.


#9

Oh, I see. Yes, they cannot be an empty array or especially a string. I assume by saying that you changed to “undefined” you meant that you simply stopped sending these fields? Or does it only work when you send attachments: undefined and repairAttachment: undefined? You shouldn’t have to send them at all.


#10

Yes by defining these values as “undefined” they are not sent as object properties to create or modify API and the UUID error is gone! thanks for support :wink:


#11