fluree / core

Fluree releases and public bug reports
0 stars 0 forks source link

`where`+`delete`+`insert` Throws Reference Object Error #49

Open aaj3f opened 8 months ago

aaj3f commented 8 months ago

Description

This is observed when running server on feature/where-syntax-update (commit SHA 7f125ccae182d4df5b1850ee64301291cf414954)

Certain where+delete+insert syntax throws an error, like in the following scenario where I want to delete any existing values on the schema:description property on ex:mosquitos and then replace them with a new insertion:

{
    "@context": "https://ns.flur.ee/",
    "ledger": "cookbook/base",
    "where": {
        "@id": "ex:mosquitos", 
        "schema:description": "?o"
    },
    "delete": {
        "@id": "ex:mosquitos", 
        "schema:description": "?o"
    },
    "insert": {
        "@id": "ex:mosquitos", 
        "schema:description": "We ❤️ All Blood"
    }
}

// =>

{
    "error": "db/invalid-query",
    "message": "Illegal reference object value"
}

Steps to Reproduce

Create Ledger

{
    "@context": "https://ns.flur.ee",
    "ledger": "cookbook/base",
    "insert": [
        {
            "@id": "ex:fluree",
            "@type": "schema:Organization",
            "schema:description": "We ❤️ Data"
        },
        {
            "@id": "ex:w3c",
            "@type": "schema:Organization",
            "schema:description": "We ❤️ Internet"
        },
        {
            "@id": "ex:mosquitos",
            "@type": "ex:Monster",
            "schema:description": "We ❤️ Human Blood"
        }
    ],
    "opts": {
        "defaultContext": {
            "ex": "http://example.org/",
            "f": "https://ns.flur.ee/ledger#",
            "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
            "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
            "schema": "http://schema.org/",
            "xsd": "http://www.w3.org/2001/XMLSchema#"
        }
    }
}

Update Data (this fails)

{
    "@context": "https://ns.flur.ee",
    "ledger": "cookbook/base",
    "where": {
        "@id": "ex:mosquitos", 
        "schema:description": "?o"
    },
    "delete": {
        "@id": "ex:mosquitos", 
        "schema:description": "?o"
    },
    "insert": {
        "@id": "ex:mosquitos", 
        "schema:description": "We ❤️ All Blood"
    }
}
cap10morgan commented 8 months ago

I was able to reproduce this in db alone, so I'll proceed with investigating it there (and fixing it there will very likely fix it in server too).

cap10morgan commented 8 months ago

Here's the full stack trace(s) I'm seeing:

ERROR f.db.query.exec.where - Error resolving flake range
 clojure.lang.ExceptionInfo: Illegal reference object value
    at fluree.db.index$for_components.invokeStatic(index.cljc:38)
    at fluree.db.index$for_components.invoke(index.cljc:28)
    at fluree.db.query.exec.where$resolve_flake_range$fn__35729.invoke(where.cljc:317)
    at fluree.db.query.exec.where$resolve_flake_range.invokeStatic(where.cljc:317)
    at fluree.db.query.exec.where$resolve_flake_range.invoke(where.cljc:303)
    at fluree.db.query.exec.update$retract_triple2$fn__38844$state_machine__7582__auto____38863$fn__38866.invoke(update.cljc:159)
    at fluree.db.query.exec.update$retract_triple2$fn__38844$state_machine__7582__auto____38863.invoke(update.cljc:137)
    at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:972)
    at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:971)
    at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:976)
    at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:974)
    at clojure.core.async.impl.ioc_macros$take_BANG_$fn__7600.invoke(ioc_macros.clj:985)
    at clojure.core.async.impl.channels.ManyToManyChannel$fn__1485$fn__1486.invoke(channels.clj:100)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at clojure.core.async.impl.concurrent$counted_thread_factory$reify__1354$fn__1355.invoke(concurrent.clj:29)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.base/java.lang.Thread.run(Thread.java:829)
 ERROR fluree.db.json-ld.api - #error {
  :cause "Illegal reference object value"
  :data {:status 400, :error :db/invalid-query}
  :via
  [{:type clojure.lang.ExceptionInfo
    :message "Illegal reference object value"
    :data {:status 400, :error :db/invalid-query}
    :at [fluree.db.index$for_components invokeStatic "index.cljc" 38]}]
  :trace
  [[fluree.db.index$for_components invokeStatic "index.cljc" 38]
   [fluree.db.index$for_components invoke "index.cljc" 28]
   [fluree.db.query.exec.where$resolve_flake_range$fn__35729 invoke "where.cljc" 317]
   [fluree.db.query.exec.where$resolve_flake_range invokeStatic "where.cljc" 317]
   [fluree.db.query.exec.where$resolve_flake_range invoke "where.cljc" 303]
   [fluree.db.query.exec.update$retract_triple2$fn__38844$state_machine__7582__auto____38863$fn__38866 invoke "update.cljc" 159]
   [fluree.db.query.exec.update$retract_triple2$fn__38844$state_machine__7582__auto____38863 invoke "update.cljc" 137]
   [clojure.core.async.impl.ioc_macros$run_state_machine invokeStatic "ioc_macros.clj" 972]
   [clojure.core.async.impl.ioc_macros$run_state_machine invoke "ioc_macros.clj" 971]
   [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invokeStatic "ioc_macros.clj" 976]
   [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invoke "ioc_macros.clj" 974]
   [clojure.core.async.impl.ioc_macros$take_BANG_$fn__7600 invoke "ioc_macros.clj" 985]
   [clojure.core.async.impl.channels.ManyToManyChannel$fn__1485$fn__1486 invoke "channels.clj" 100]
   [clojure.lang.AFn run "AFn.java" 22]
   [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
   [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
   [clojure.core.async.impl.concurrent$counted_thread_factory$reify__1354$fn__1355 invoke "concurrent.clj" 29]
   [clojure.lang.AFn run "AFn.java" 22]
   [java.lang.Thread run "Thread.java" 829]]}
 ERROR fluree.db.json-ld.api - #error {
  :cause "class clojure.lang.ExceptionInfo cannot be cast to class clojure.lang.Associative (clojure.lang.ExceptionInfo and clojure.lang.Associative are in unnamed module of loader 'app')"
  :via
  [{:type java.lang.ClassCastException
    :message "class clojure.lang.ExceptionInfo cannot be cast to class clojure.lang.Associative (clojure.lang.ExceptionInfo and clojure.lang.Associative are in unnamed module of loader 'app')"
    :at [clojure.lang.RT assoc "RT.java" 827]}]
  :trace
  [[clojure.lang.RT assoc "RT.java" 827]
   [clojure.core$assoc__5481 invokeStatic "core.clj" 193]
   [clojure.core$assoc_in invokeStatic "core.clj" 6204]
   [clojure.core$assoc_in invoke "core.clj" 6196]
   [fluree.db.api.query$restrict_db$fn__64095$state_machine__7582__auto____64102$fn__64105 invoke "query.cljc" 119]
   [fluree.db.api.query$restrict_db$fn__64095$state_machine__7582__auto____64102 invoke "query.cljc" 112]
   [clojure.core.async.impl.ioc_macros$run_state_machine invokeStatic "ioc_macros.clj" 972]
   [clojure.core.async.impl.ioc_macros$run_state_machine invoke "ioc_macros.clj" 971]
   [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invokeStatic "ioc_macros.clj" 976]
   [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invoke "ioc_macros.clj" 974]
   [fluree.db.api.query$restrict_db$fn__64095 invoke "query.cljc" 112]
   [clojure.lang.AFn run "AFn.java" 22]
   [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
   [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
   [clojure.core.async.impl.concurrent$counted_thread_factory$reify__1354$fn__1355 invoke "concurrent.clj" 29]
   [clojure.lang.AFn run "AFn.java" 22]
   [java.lang.Thread run "Thread.java" 829]]}
 ERROR fluree.db.index - Error resolving index node: {}
 java.lang.IllegalArgumentException: sorted-map-by: no value supplied for key: {:leaf true, :size 0, :leftmost? true, :ledger-alias nil, :id :empty, :tempid #uuid "9f2937c6-bea5-4081-a6da-608c4bf65025", :comparator nil, :t 0, :first #Flake [-9223372036854775808 17592186044415 -9223372036854775808 2147483647 -9223372036854775808 true 2147483647], :rhs nil}
    at clojure.data.avl$sorted_map_by.invokeStatic(avl.clj:1917)
    at clojure.data.avl$sorted_map_by.doInvoke(avl.clj:1904)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$apply.invoke(core.clj:662)
    at fluree.db.flake$sorted_map_by.invokeStatic(flake.cljc:474)
    at fluree.db.flake$sorted_map_by.doInvoke(flake.cljc:472)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at fluree.db.storage$resolve_empty_branch.invokeStatic(storage.cljc:286)
    at fluree.db.storage$resolve_empty_branch.invoke(storage.cljc:282)
    at fluree.db.storage$resolve_empty_node.invokeStatic(storage.cljc:298)
    at fluree.db.storage$resolve_empty_node.invoke(storage.cljc:291)
    at fluree.db.conn.memory.MemoryConnection.resolve(memory.cljc:127)
    at fluree.db.index$resolve_t_range$fn__11211$state_machine__7582__auto____11222$fn__11225.invoke(index.cljc:248)
    at fluree.db.index$resolve_t_range$fn__11211$state_machine__7582__auto____11222.invoke(index.cljc:247)
    at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:972)
    at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:971)
    at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:976)
    at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:974)
    at fluree.db.index$resolve_t_range$fn__11211.invoke(index.cljc:247)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at clojure.core.async.impl.concurrent$counted_thread_factory$reify__1354$fn__1355.invoke(concurrent.clj:29)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.base/java.lang.Thread.run(Thread.java:829)
cap10morgan commented 8 months ago

This was fixed by other fixes that just landed on main.