orientdb
orientdb copied to clipboard
NPE when creating vertex with link via studio
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
- I installed orientDB, edited orientdb.sh (properly set
ORIENTDB_DIR
undORIENTDB_USER
) and run it withstart
arg. - I opened studio at http://localhost:2480/ and logged in
- I created a new vertex
Country
with some string properties - I created a new vertex
Address
with some string properties and a link property calledCountry
pointing toCounty
vertex and with min=1, max=1, mandatory=true and not null = true. - I created a record of
Country
with all properties filled and noted its RID - I created a record of
Address
with all properties filled and theCountry
property set to the before noted RID.
At 6. saving failed with the above exception.
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
This seems to be related to the fact that I set min
and max
in the link property to 1
. Is that invalid?
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 Country
property 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.