Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrientDB.RequestError: Found class name null or empty #141

Closed
fridaystreet opened this issue Nov 27, 2015 · 1 comment
Closed

OrientDB.RequestError: Found class name null or empty #141

fridaystreet opened this issue Nov 27, 2015 · 1 comment

Comments

@fridaystreet
Copy link

Apologies if this is the wrong place to raise this, but I'm not really sure where to start with it. I don't think it's to do with oriento, I think it's higher up the stack, so I thought I'd just start here.

I'm trying to create a record with a many to many relationship. I've debugged the issue and found the sequence of events that is causing it, but I don't know where the actual root cause is. It's quite a strange issue.

my models are order and role (detailed below). I'm attempting to create an order and associate it to a role (already existing record) that has permissions relating to who can access the order. If I create the order without the role attribute populated all works fine. In fact even if I do populate the role attribute, the order itself is created, but the error (full error at bottom of post) occurs after that and before the relationship is created.

module.exports = {
identity: 'Order',
attributes: {
deliveryAddress: { type: 'json' },
deliveryContact: { type: 'json' },
billingAddress: { type: 'json' },
billingContact: { type: 'json' },
total: { type: 'integer' },
tax: { type: 'integer' },
status: { type: 'string' },
paymentRef: { type: 'string' },
paymentToken: { type: 'string' },
accessedby: {
collection: 'role',
via: 'canaccessorder',
dominant: false
}
}
};

module.exports = {
identity: 'Role',
joinTableNames : {
canaccessorder : 'canAccessOrder'
},
attributes: {
name: { type: 'string'},
create: {type: 'boolean'},
read: {type: 'boolean'},
update: {type: 'boolean'},
delete: {type: 'boolean' },
user: {
collection : 'user',
via : 'hasrole',
dominant : false
},
canaccessdashboard: {
collection : 'dashboard',
via : 'accessedby',
dominant : true
},
};

When I include the role, after the insert command is sent and the order is created and update command is sent to the same order. This only happens if I include the role. I'm not sure why the same data is sent in an update straight after the insert. Which is the bit I'm not sure if waterline or sails-orientdb is the issue.

Anyway I've worked out that the error is being thrown because the data for the address attribute of the order which is sails type json (orient type embedded) for some reason is having an @Class='' added to json blob before it sends the update query. I worked back through the stacktrace and got as far as

"at Server.send (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/server/index.js:128:25)"

I wanted to confirm the data being sent so in that function I added

  • if(options && options.hasOwnProperty('params')){
    for(var p in options.params.params){
    var params = options.params.params[p];
    console.log('param name: '+p);
    console.log(params);
    }
    }*

which outputted the following for the Insert command

param name: param0
{ [String: '#21:10'] cluster: 21, position: 10 }
param name: paramname0
null
param name: paramtype1
physical
param name: paramidentifier2
34 Newcastle Street6000
param name: paramprovider3
local
param name: paramsummary4
delivery
param name: paramaddress5
"{"addressLine1":"34 Newcastle Street","addressLine2":null,"city":"Perth","state":"WA","postcode":"6000","country":"au","latitude":"-31.9494209","longitude":"115.8672028"}"
param name: paramcreatedAt6
Fri Nov 27 2015 03:10:18 GMT+0000 (UTC)
param name: paramupdatedAt7
Fri Nov 27 2015 03:10:18 GMT+0000 (UTC)

followed by this for the update command

param name: param0
{ [String: '#22:23'] cluster: 22, position: 23 }
param name: paramdeliveryAddress0
{ '@type': 'd',
'@Class': '',
type: 'document',
state: 'WA',
longitude: '115.8672028',
latitude: '-31.9494209',
postcode: '6000',
addressLine2: null,
addressLine1: '34 Newcastle Street',
country: 'au',
city: 'Perth' }
param name: paramdeliveryContact1
{ '@type': 'document',
businessName: null,
phone: null,
fullName: 'Joe Bloggs',
abn: null }
param name: parambillingAddress2
{ '@type': 'd',
'@Class': '',
type: 'document',
state: 'WA',
longitude: '115.8672028',
latitude: '-31.9494209',
postcode: '6000',
addressLine2: null,
addressLine1: '34 Newcastle Street',
country: 'au',
city: 'Perth' }
param name: parambillingContact3
{ '@type': 'document',
businessName: null,
phone: null,
fullName: 'Joe Bloggs',
abn: null }
param name: paramtotal4
9900
param name: paramtax5
900
param name: paramstatus6
pending confirmation
param name: parampaymentRef7
null
param name: parampaymentToken8
tok_17BKE5Cz7G29pptK3kCL133x
param name: paramcreatedAt9
Fri Nov 27 2015 03:10:18 GMT+0000 (UTC)
param name: paramupdatedAt10
Fri Nov 27 2015 03:10:18 GMT+0000 (UTC)

So the strange thing here is that the 2 address fields have both had @Class='' added to them, but the 2 contact fields haven't. All 4 of these fields are defined exactly the same way and when I look at the order in the database, none of the address fields have the @Class='' in the actual stored document. So something is adding it in before the update query and I have no clue why just for those 2 fields and not the other 2 json fields in the model.

As a workaround for now I've just added this to that same send function, but I have no clue if it's going to break anything else. I'm assuming that it's safe to say that no type of document in orient should have an @Class property that is blank.

  • if(options && options.hasOwnProperty('params')){
    for(var p in options.params.params){
    var params = options.params.params[p];
    console.log('param name: '+p);
    console.log(params);
    if(typeof(params) == 'object' && params !== null){
    if(params.hasOwnProperty('@type') && params.hasOwnProperty('@Class')){
    if(params['@type'] == 'd' && params['@Class'] == ''){
    delete options.params.params[p]['@Class'];
    }
    }
    }
    }
    }*

Apologies for the length, but here is a full trace of the operation with oriento debugging on and the extra output of the parameters I added to the send function.

param name: param0
{ [String: '#27:0'] cluster: 27, position: 0 }
sending operation command for database frontend
param name: param0
#27:0

param name: param1
#26:5

executing query against db frontend: CREATE EDGE hasRole FROM #27:0 TO #26:5 SET @Class = :paramclass0
sending operation command for database frontend
param name: paramclass0
hasRole
executing query against db frontend: SELECT name, create, read, update, delete, @Rid, createdAt, updatedAt, in_hasRole, out_canAccessLocation, out_canAccessBusiness, out_canAccessCommunity, out_canAccessOrder FROM role WHERE @Rid = :param0
sending operation command for database frontend
param name: param0
executing query against db frontend: INSERT INTO order SET deliveryAddress = :paramdeliveryAddress0, deliveryContact = :paramdeliveryContact1, billingAddress = :parambillingAddress2, billingContact = :parambillingContact3, total = :paramtotal4, tax = :paramtax5, status = :paramstatus6, paymentRef = :parampaymentRef7, paymentToken = :parampaymentToken8, createdAt = :paramcreatedAt9, updatedAt = :paramupdatedAt10
sending operation command for database frontend
param name: paramdeliveryAddress0
{ addressLine1: '34 Newcastle Street',
addressLine2: null,
city: 'Perth',
state: 'WA',
postcode: '6000',
country: 'au',
latitude: '-31.9494209',
longitude: '115.8672028',
'@type': 'd' }
param name: paramdeliveryContact1
{ fullName: 'Joe Bloggs',
businessName: null,
abn: null,
phone: null,
'@type': 'd' }
param name: parambillingAddress2
{ addressLine1: '34 Newcastle Street',
addressLine2: null,
city: 'Perth',
state: 'WA',
postcode: '6000',
country: 'au',
latitude: '-31.9494209',
longitude: '115.8672028',
'@type': 'd' }
param name: parambillingContact3
{ fullName: 'Joe Bloggs',
businessName: null,
abn: null,
phone: null,
'@type': 'd' }
param name: paramtotal4
9900
param name: paramtax5
900
param name: paramstatus6
pending confirmation
param name: parampaymentRef7
null
param name: parampaymentToken8
tok_17BKE5Cz7G29pptK3kCL133x
param name: paramcreatedAt9
Fri Nov 27 2015 03:41:24 GMT+0000 (UTC)
param name: paramupdatedAt10
Fri Nov 27 2015 03:41:24 GMT+0000 (UTC)
executing query against db frontend: UPDATE order SET deliveryAddress = :paramdeliveryAddress0, deliveryContact = :paramdeliveryContact1, billingAddress = :parambillingAddress2, billingContact = :parambillingContact3, total = :paramtotal4, tax = :paramtax5, status = :paramstatus6, paymentRef = :parampaymentRef7, paymentToken = :parampaymentToken8, createdAt = :paramcreatedAt9, updatedAt = :paramupdatedAt10 RETURN AFTER WHERE @Rid = :param0
sending operation command for database frontend
param name: param0
{ [String: '#22:24'] cluster: 22, position: 24 }
param name: paramdeliveryAddress0
{ '@type': 'd',
'@Class': '',
type: 'document',
state: 'WA',
longitude: '115.8672028',
latitude: '-31.9494209',
postcode: '6000',
addressLine2: null,
addressLine1: '34 Newcastle Street',
country: 'au',
city: 'Perth' }
param name: paramdeliveryContact1
{ '@type': 'document',
businessName: null,
phone: null,
fullName: 'Joe Bloggs',
abn: null }
param name: parambillingAddress2
{ '@type': 'd',
'@Class': '',
type: 'document',
state: 'WA',
longitude: '115.8672028',
latitude: '-31.9494209',
postcode: '6000',
addressLine2: null,
addressLine1: '34 Newcastle Street',
country: 'au',
city: 'Perth' }
param name: parambillingContact3
{ '@type': 'document',
businessName: null,
phone: null,
fullName: 'Joe Bloggs',
abn: null }
param name: paramtotal4
9900
param name: paramtax5
900
param name: paramstatus6
pending confirmation
param name: parampaymentRef7
null
param name: parampaymentToken8
tok_17BKE5Cz7G29pptK3kCL133x
param name: paramcreatedAt9
Fri Nov 27 2015 03:41:24 GMT+0000 (UTC)
param name: paramupdatedAt10
Fri Nov 27 2015 03:41:24 GMT+0000 (UTC)
Fri, 27 Nov 2015 03:41:25 GMT: error: Sending 500 ("Server Error") response:
Error (E_UNKNOWN) :: Encountered an unexpected error
OrientDB.RequestError: Found class name null or empty
at Operation.parseError (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/transport/binary/protocol28/operation.js:836:13)
at Operation.consume (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/transport/binary/protocol28/operation.js:422:35)
at Connection.process (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/transport/binary/connection.js:360:17)
at Connection.handleSocketData (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/transport/binary/connection.js:279:17)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20)
From previous event:
at Connection._sendOp (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/transport/binary/connection.js:79:10)
at Connection.send (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/transport/binary/connection.js:63:17)
at BinaryTransport.send (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/transport/binary/index.js:191:43)
at Server.send (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/server/index.js:128:25)
at Db. (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/db/index.js:152:24)
at processImmediate as _immediateCallback
From previous event:
at Db.send (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/db/index.js:144:4)
at Db.exec (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/db/index.js:247:22)
at Db.query (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/db/index.js:279:15)
at module.exports.Statement.extend.exec (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/db/query.js:108:20)
at module.exports.Statement.extend.all (/home/app/ec/server/node_modules/sails-orientdb/node_modules/oriento/lib/db/query.js:70:17)
at update (/home/app/ec/server/node_modules/sails-orientdb/lib/collection/document.js:201:6)
at Connection.update (/home/app/ec/server/node_modules/sails-orientdb/lib/connection.js:381:32)
at Object.module.exports.adapter.update (/home/app/ec/server/node_modules/sails-orientdb/lib/adapter.js:309:38)
at module.exports.update (/home/app/ec/server/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:241:13)
at bound.updateRecords (/home/app/ec/server/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/update.js:201:16)
at /home/app/ec/server/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/update.js:52:21
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:708:13
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:263:32
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:705:17
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:49:16
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:263:32
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16
at bound. (/home/app/ec/server/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:151:44)
at fn (/home/app/ec/server/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:79:10)
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:162:20
at iterate (/home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:256:13)
at Object.async.forEachOfSeries.async.eachOfSeries (/home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:275:9)
at Object.async.forEachSeries.async.eachSeries (/home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:211:22)
at Object.runner.beforeUpdate (/home/app/ec/server/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:82:9)
at /home/app/ec/server/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/update.js:169:17
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:699:13
at iterate (/home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:256:13)
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:268:29
at /home/app/ec/server/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:40:16

Details: OrientDB.RequestError: Found class name null or empty

@dmarcelino
Copy link
Member

dmarcelino commented Jul 4, 2016

Hi @fridaystreet, this looks like a duplicate of #116 (which was fixed by #119). Were you using sails-orientdb master branch? Please reopen the issue if that doesn't fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants