commontoolsinc / synopsys

datastore service for datums
2 stars 1 forks source link

Referencing variable in `select` without reference in `where` crashes process #56

Open bfollington opened 1 week ago

bfollington commented 1 week ago

Not 100% sure if this is a synopsys or datalogia issue?

Selecting a variable that is not referenced in a where clause triggers a null reference exception when trying to create a merkle reference.

Query that triggers crash:

{
  "select": {
    "form": {
      "?": { "id": 3 }
    },
    "self": {
      "?": { "id": 1 }
    },
    "url": {
      "?": { "id": 2 }
    }
  },
  "where": [
    {
      "Match": [ { "/": "baedreihd5k5oi763a3h5eafcanan3oprjmjnkv2bv7bk2qavikczwmgwmi" }, "==", { "?": { "id": 1 } } ]
    },
    {
      "Case": [ { "?": { "id": 1 } }, "url", { "?": { "id": 2 } } ]
    },
    {
      "Not": {
        "Case": [ { "?": { "id": 1 } }, "my/request", { "?": { "id": 4 } }
        ]
      }
    }
  ]
}
file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/type.js:38
      throw new TypeError(`Unknown type ${String.toString(data)}`)
            ^

TypeError: Unknown type undefined
    at Module.infer (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/type.js:38:13)
    at toTree (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/lib.js:30:21)
    at attributes (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/map.js:37:14)
    at Module.toTree (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/map.js:51:16)
    at toTree (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/lib.js:32:15)
    at Module.toTree (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/list.js:13:18)
    at toTree (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/lib.js:32:15)
    at refer (file:///Users/ben/code/common-tools/synopsys/node_modules/merkle-reference/src/lib.js:49:36)
    at of (file:///Users/ben/code/common-tools/synopsys/src/datum/reference.js:102:59)
    at LocalSource.poll (file:///Users/ben/code/common-tools/synopsys/src/replica/session/local.js:148:22)

Node.js v20.17.0