Uploaded image for project: 'PuppetDB'
  1. PuppetDB
  2. PDB-4232

Use of 'in' operator with ast_only: true causes NullPointerException

    Details

    • Template:
    • Team:
      PuppetDB
    • Method Found:
      Needs Assessment
    • Zendesk Ticket IDs:
      33131
    • Zendesk Ticket Count:
      1
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Valid PQL queries, which use the 'in' operator to compare against an array, that are being converted to AST (via the ast_only option) will no longer throw a NullPointerException.
      Show
      Valid PQL queries, which use the 'in' operator to compare against an array, that are being converted to AST (via the ast_only option) will no longer throw a NullPointerException.
    • QA Risk Assessment:
      Needs Assessment

      Description

      The following query will succeed.

      $ curl -X POST http://localhost:8080/pdb/query/v4   -H 'Content-Type:application/json'   -d 
           '{
             "query":
               "facts[certname]{
                 name = \"ipaddress\"
                 and value in [\"192.168.0.10\"]
               }"
            }'
      

      But when you add the ast_only flag, set to true, the query will fail

      $ curl -X POST http://localhost:8080/pdb/query/v4   -H 'Content-Type:application/json'   -d 
           '{
             "query":
               "facts[certname]{
                 name = \"ipaddress\"
                 and value in [\"192.168.0.10\"]
               }",
               "ast_only": true
            }'
      

      The error looks like this

      <body><h2>HTTP ERROR 500</h2>
      <p>Problem accessing /pdb/query/v4. Reason:
      <pre>    Server Error</pre></p><h3>Caused by:</h3><pre>java.lang.NullPointerException
              at puppetlabs.puppetdb.scf.storage_utils$array_to_param.invokeStatic(storage_utils.clj:25)
              at puppetlabs.puppetdb.scf.storage_utils$array_to_param.invoke(storage_utils.clj:23)
              at puppetlabs.puppetdb.query_eng.engine$user_node__GT_plan_node$fn__33385$fn__33387.invoke(engine.clj:1883)
              at puppetlabs.puppetdb.query_eng.engine$user_node__GT_plan_node$fn__33385.invoke(engine.clj:1809)
              at puppetlabs.puppetdb.query_eng.engine$user_node__GT_plan_node.invokeStatic(engine.clj:1809)
              at puppetlabs.puppetdb.query_eng.engine$user_node__GT_plan_node.invoke(engine.clj:1806)
              at puppetlabs.puppetdb.query_eng.engine$user_node__GT_plan_node$fn__33405$fn__33406.invoke(engine.clj:1956)
              at clojure.core$map$fn__5587.invoke(core.clj:2747)
              at clojure.lang.LazySeq.sval(LazySeq.java:40)
              at clojure.lang.LazySeq.seq(LazySeq.java:49)
              at clojure.lang.Cons.next(Cons.java:39)
              at clojure.lang.LazySeq.next(LazySeq.java:81)
              at clojure.lang.RT.next(RT.java:706)
              at clojure.core$next__5108.invokeStatic(core.clj:64)
              at clojure.core$next__5108.invoke(core.clj:64)
              at fast_zip.core$down.invokeStatic(core.clj:116)
              at fast_zip.core$down.invoke(core.clj:104)
              at fast_zip.visit$visit.invokeStatic(visit.clj:47)
              at fast_zip.visit$visit.invoke(visit.clj:32)
              at puppetlabs.puppetdb.zip$post_order_visit.invokeStatic(zip.clj:87)
              at puppetlabs.puppetdb.zip$post_order_visit.invoke(zip.clj:82)
              at puppetlabs.puppetdb.query_eng.engine$extract_all_params.invokeStatic(engine.clj:1353)
              at puppetlabs.puppetdb.query_eng.engine$extract_all_params.invoke(engine.clj:1349)
              at puppetlabs.puppetdb.query_eng.engine$compile_user_query__GT_sql.invokeStatic(engine.clj:2338)
              at puppetlabs.puppetdb.query_eng.engine$compile_user_query__GT_sql.doInvoke(engine.clj:2326)
              at clojure.lang.RestFn.invoke(RestFn.java:442)
              at puppetlabs.puppetdb.query_eng$query__GT_sql.invokeStatic(query_eng.clj:109)
              at puppetlabs.puppetdb.query_eng$query__GT_sql.invoke(query_eng.clj:85)
              at puppetlabs.puppetdb.http.query$valid_query_QMARK_.invokeStatic(query.clj:369)
              at puppetlabs.puppetdb.http.query$valid_query_QMARK_.invoke(query.clj:366)
              at puppetlabs.puppetdb.http.query$query_handler$fn__36982.invoke(query.clj:375)
              at clojure.core$comp$fn__5529.invoke(core.clj:2561)
              at puppetlabs.puppetdb.http.query$extract_query$fn__36968.invoke(query.clj:311)
              at compojure.response$eval2968$fn__2969.invoke(response.clj:33)
              at compojure.response$eval2923$fn__2924$G__2914__2931.invoke(response.clj:6)
              at puppetlabs.puppetdb.http.handlers$eval37122$root_routes__37127$fn__37128$fn__37132.invoke(handlers.clj:60)
              at bidi.ring$eval35419$fn__35420.invoke(ring.cljc:25)
              at bidi.ring$eval35398$fn__35399$G__35389__35408.invoke(ring.cljc:16)
              at puppetlabs.puppetdb.middleware$eval36143$make_pdb_handler__36152$fn__36155$fn__36157.invoke(middleware.clj:336)
              at puppetlabs.puppetdb.middleware$wrap_with_illegal_argument_catch$fn__36038.invoke(middleware.clj:99)
              at puppetlabs.puppetdb.middleware$verify_accepts_content_type$fn__36042.invoke(middleware.clj:114)
              at puppetlabs.puppetdb.middleware$verify_content_type$fn__36054.invoke(middleware.clj:144)
              at puppetlabs.puppetdb.middleware$wrap_with_metrics$fn__36070$fn__36079.invoke(middleware.clj:239)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__34208$fn__34209$fn__34210.invoke(metrics.clj:14)
              at puppetlabs.puppetdb.utils.metrics.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source)
              at com.codahale.metrics.Timer.time(Timer.java:101)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__34208$fn__34209.invoke(metrics.clj:14)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__34208$fn__34209$fn__34210.invoke(metrics.clj:14)
              at puppetlabs.puppetdb.utils.metrics.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source)
              at com.codahale.metrics.Timer.time(Timer.java:101)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__34208$fn__34209.invoke(metrics.clj:14)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__34208$fn__34209$fn__34210.invoke(metrics.clj:14)
              at puppetlabs.puppetdb.utils.metrics.proxy$java.lang.Object$Callable$7da976d4.call(Unknown Source)
              at com.codahale.metrics.Timer.time(Timer.java:101)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__34208$fn__34209.invoke(metrics.clj:14)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_.invokeStatic(metrics.clj:17)
              at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_.invoke(metrics.clj:6)
              at puppetlabs.puppetdb.middleware$wrap_with_metrics$fn__36070.invoke(middleware.clj:238)
              at puppetlabs.puppetdb.middleware$wrap_with_globals$fn__36033.invoke(middleware.clj:93)
              at puppetlabs.puppetdb.http.server$build_app$fn__37703.invoke(server.clj:74)
              at compojure.core$routing$fn__4798.invoke(core.clj:151)
              at clojure.core$some.invokeStatic(core.clj:2693)
              at clojure.core$some.invoke(core.clj:2684)
              at compojure.core$routing.invokeStatic(core.clj:151)
              at compojure.core$routing.doInvoke(core.clj:148)
              at clojure.lang.RestFn.invoke(RestFn.java:423)
              at puppetlabs.puppetdb.pdb_routing$wrap_with_context$fn__50699.invoke(pdb_routing.clj:35)
              at compojure.core$if_context$fn__4862.invoke(core.clj:218)
              at compojure.core$routing$fn__4798.invoke(core.clj:151)
              at clojure.core$some.invokeStatic(core.clj:2693)
              at clojure.core$some.invoke(core.clj:2684)
              at compojure.core$routing.invokeStatic(core.clj:151)
              at compojure.core$routing.doInvoke(core.clj:148)
              at clojure.lang.RestFn.applyTo(RestFn.java:139)
              at clojure.core$apply.invokeStatic(core.clj:659)
              at clojure.core$apply.invoke(core.clj:652)
              at compojure.core$routes$fn__4802.invoke(core.clj:156)
              at compojure.core$routing$fn__4798.invoke(core.clj:151)
              at clojure.core$some.invokeStatic(core.clj:2693)
              at clojure.core$some.invoke(core.clj:2684)
              at compojure.core$routing.invokeStatic(core.clj:151)
              at compojure.core$routing.doInvoke(core.clj:148)
              at clojure.lang.RestFn.invoke(RestFn.java:460)
              at puppetlabs.puppetdb.pdb_routing$pdb_app$fn__50710.invoke(pdb_routing.clj:62)
              at compojure.core$if_context$fn__4862.invoke(core.clj:218)
              at ring.middleware.params$wrap_params$fn__34312.invoke(params.clj:64)
              at puppetlabs.puppetdb.middleware$wrap_with_certificate_cn$fn__36023.invoke(middleware.clj:75)
              at puppetlabs.puppetdb.middleware$wrap_with_default_body$fn__36028.invoke(middleware.clj:82)
              at puppetlabs.puppetdb.middleware$wrap_with_debug_logging$fn__36006.invoke(middleware.clj:39)
              at puppetlabs.i18n.core$locale_negotiator$fn__124.invoke(core.clj:357)
              at puppetlabs.trapperkeeper.services.webserver.jetty9_core$ring_handler$fn__43141.invoke(jetty9_core.clj:434)
              at puppetlabs.trapperkeeper.services.webserver.jetty9_core.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source)
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
              at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)
              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:205)
              at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)
              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
              at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219)
              at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
              at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:724)
              at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:169)
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
              at org.eclipse.jetty.server.Server.handle(Server.java:531)
              at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
              at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
              at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
              at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
              at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
              at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
              at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)
              at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)
              at java.base/java.lang.Thread.run(Thread.java:844)
      
      

        Attachments

          Activity

            People

            • Assignee:
              austin.blatt Austin Blatt
              Reporter:
              austin.blatt Austin Blatt
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support