LionWeb-io / lionweb-repository

Reference implementation of LionWeb repository
Apache License 2.0
2 stars 1 forks source link

retrieve infinite depth crashes #12

Closed enikao closed 6 months ago

enikao commented 6 months ago
Api.getNodes: {"ids":["partition-id","midnode-id","leaf-id"]} depth NaN
LionWebQueries.getNodeTree for partition-id,midnode-id,leaf-id
C:\Users\Niko\git\lionweb\lionweb-repository\node_modules\pg-protocol\dist\parser.js:287
        const message = name === 'notice' ? new messages_1.NoticeMessage(length, messageValue) : new messages_1.DatabaseError(messageValue, length, name);
                                                                                                 ^

error: column "nan" does not exist
    at Parser.parseErrorMessage (C:\Users\Niko\git\lionweb\lionweb-repository\node_modules\pg-protocol\dist\parser.js:287:98)
    at Parser.handlePacket (C:\Users\Niko\git\lionweb\lionweb-repository\node_modules\pg-protocol\dist\parser.js:126:29)
    at Parser.parse (C:\Users\Niko\git\lionweb\lionweb-repository\node_modules\pg-protocol\dist\parser.js:39:38)
    at Socket.<anonymous> (C:\Users\Niko\git\lionweb\lionweb-repository\node_modules\pg-protocol\dist\index.js:11:42)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 104,
  severity: 'ERROR',
  code: '42703',
  detail: undefined,
  hint: undefined,
  position: '433',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'parse_relation.c',
  line: '3713',
  routine: 'errorMissingColumn',
  query: '\n' +
    'WITH RECURSIVE tmp AS (\n' +
    '    SELECT id, parent, 0 as depth -- , con.children\n' +
    '    FROM lionweb_nodes\n' +
    '    LEFT JOIN (SELECT children, node_id FROM lionweb_containments) con ON con.node_id = id\n' +
    "    WHERE id IN ('partition-id', 'midnode-id', 'leaf-id')    \n" +
    '    UNION\n' +
    '        SELECT nn.id, nn.parent, tmp.depth + 1 -- , con.children\n' +
    '        FROM lionweb_nodes as nn\n' +
    '        INNER JOIN tmp ON tmp.id = nn.parent\n' +
    '        WHERE tmp.depth < NaN -- AND nn.id NOT in otherArray\n' +
    ')\n' +
    'SELECT * FROM tmp;\n' +
    '    ',
  params: undefined
}

Node.js v21.4.0
joswarmer commented 6 months ago

What number did you use to get infinite depth?

enikao commented 6 months ago

As per spec, none (i.e. don't send that parameter)

joswarmer commented 6 months ago

Ok, that should work :-( . DO you have the code / data to get this error? I added a lot of checks lately, it might already be fixed by these. If not I'll investigate.

enikao commented 6 months ago

The first line mentions the parameters: method retrieve, three node ids (all unknown), no depth

joswarmer commented 6 months ago

Found the problem, the check on the value of the optional depth limit parameter was not strict enough.

joswarmer commented 6 months ago

Fix merged to main