orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

NPE when creating vertex with link via studio

Open hohwille opened this issue 4 years ago • 3 comments

OrientDB Version: orientdb-3.1.6

Java Version: 11.0.5

OS: mac os x (10.15.7, x86_64)

Expected behavior

I want to be able to create a new vertex that has a mandatory link property.

Actual behavior

NPE when saving the new vertex:

Internal server error:

java.lang.NullPointerException
        at com.orientechnologies.orient.core.record.impl.ODocument.validateField(ODocument.java:786)
        at com.orientechnologies.orient.core.record.impl.ODocument.validate(ODocument.java:2625)
        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.saveInternal(ODatabaseDocumentAbstract.java:1830)
        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:1802)
        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentAbstract.save(ODatabaseDocumentAbstract.java:135)
        at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2361)
        at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:2350)
        at com.orientechnologies.orient.server.network.protocol.http.command.post.OServerCommandPostDocument.execute(OServerCommandPostDocument.java:54)
        at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.service(ONetworkProtocolHttpAbstract.java:253)
        at com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpAbstract.execute(ONetworkProtocolHttpAbstract.java:811)
        at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:67)

Steps to reproduce

  1. I installed orientDB, edited orientdb.sh (properly set ORIENTDB_DIR und ORIENTDB_USER) and run it with start arg.
  2. I opened studio at http://localhost:2480/ and logged in
  3. I created a new vertex Country with some string properties
  4. I created a new vertex Address with some string properties and a link property called Country pointing to County vertex and with min=1, max=1, mandatory=true and not null = true.
  5. I created a record of Country with all properties filled and noted its RID
  6. I created a record of Address with all properties filled and the Country property set to the before noted RID.

At 6. saving failed with the above exception.

hohwille avatar Jan 03 '21 20:01 hohwille

Here is the link to the line causing the NPE: https://github.com/orientechnologies/orientdb/blob/bcef56923b1b1a3017d6670761b148a6a6d92004/core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocument.java#L786

hohwille avatar Jan 03 '21 20:01 hohwille

This seems to be related to the fact that I set min and max in the link property to 1. Is that invalid?

hohwille avatar Jan 03 '21 20:01 hohwille

I updated my Address vertex and removed min and max values from existing Country property. After reloading the schema of Address the value of min in property Country was displayed as null and it seems as resetting min is not really possible - until then creating a new record still caused the NPE. So I dropped Countryproperty and created it again without min or max and now creating the record works without this NPE. Maybe you should consider validating the creation of properties more carefully if min=1 is invalid for link properties. And even better for UX: also disable the min and max fields in studio for all property types that can not have them.

hohwille avatar Jan 03 '21 20:01 hohwille