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

"null?" query of facts against the query/v4/nodes endpoint results in "Value does not match schema" errors

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Accepted
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: PDB 4.2.3.5, PDB 5.1.4, PDB 5.2.4, PDB 5.2.7, PDB 6.0.2
    • Fix Version/s: None
    • Component/s: None
    • Template:
    • Acceptance Criteria:
      Hide

      Either queries on "null?" values of facts against the nodes endpoint work, or we document that they won't and why not.

      Show
      Either queries on "null?" values of facts against the nodes endpoint work, or we document that they won't and why not.
    • Team:
      PuppetDB
    • Method Found:
      Customer Feedback
    • CS Priority:
      Reviewed
    • Zendesk Ticket IDs:
      34133
    • Zendesk Ticket Count:
      1
    • QA Risk Assessment:
      Needs Assessment

      Description

      Steps to reproduce

      Query a running PDB instance for nodes where a fact is or is not null:

      curl -sX GET http://localhost:8080/pdb/query/v4/nodes --data-urlencode 'query=["null?", ["fact", "id"], false]'
      

      Expected behavior

      The response contains the matching list of nodes.

      Observed behavior

      HTTP ERROR 500
       
      Problem accessing /pdb/query/v4/nodes. Reason:
       
          Server Error
      Caused by:
      clojure.lang.ExceptionInfo: Value does not match schema: (not (map? nil)) {:type :schema.core/error, :schema {:type Keyword, :field (cond-pre Keyword honeysql.types.SqlCall honeysql.types.SqlRaw {:select Any, Any Any}), Any Any}, :value nil, :error (not (map? nil))}
      	at schema.core$validator$fn__7917.invoke(core.clj:155)
      	at schema.core$validate.invokeStatic(core.clj:164)
      	at schema.core$validate.invoke(core.clj:159)
      	at puppetlabs.puppetdb.query_eng.engine$eval34226$fn__34228.invoke(engine.clj:1228)
      	at puppetlabs.puppetdb.query_eng.engine$eval34156$fn__34157$G__34147__34162.invoke(engine.clj:1130)
      	at clojure.core$map$fn__4785.invoke(core.clj:2646)
      	at clojure.lang.LazySeq.sval(LazySeq.java:40)
      	at clojure.lang.LazySeq.seq(LazySeq.java:56)
      	at clojure.lang.ChunkedCons.chunkedNext(ChunkedCons.java:59)
      	at clojure.lang.ChunkedCons.next(ChunkedCons.java:43)
      	at clojure.lang.RT.next(RT.java:688)
      	at clojure.core$next__4341.invokeStatic(core.clj:64)
      	at clojure.core$nthnext.invokeStatic(core.clj:3062)
      	at clojure.core$nthnext.invoke(core.clj:3055)
      	at honeysql.format$format_predicate_STAR_.invokeStatic(format.clj:359)
      	at honeysql.format$format_predicate_STAR_.invoke(format.clj:356)
      	at honeysql.format$eval29381$fn__29383.invoke(format.clj:414)
      	at clojure.lang.MultiFn.invoke(MultiFn.java:233)
      	at honeysql.format$_format_clause.invokeStatic(format.clj:394)
      	at honeysql.format$_format_clause.invoke(format.clj:391)
      	at honeysql.format$eval29313$fn__29314$fn__29315$fn__29316.invoke(format.clj:326)
      	at clojure.core$comp$fn__4727.invoke(core.clj:2460)
      	at clojure.core$map$fn__4785.invoke(core.clj:2646)
      	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.RT.next(RT.java:688)
      	at clojure.core$next__4341.invokeStatic(core.clj:64)
      	at clojure.string$join.invokeStatic(string.clj:191)
      	at clojure.string$join.invoke(string.clj:180)
      	at honeysql.format$space_join.invokeStatic(format.clj:15)
      	at honeysql.format$space_join.invoke(format.clj:14)
      	at honeysql.format$eval29313$fn__29314$fn__29315.invoke(format.clj:325)
      	at honeysql.format$eval29313$fn__29314.invoke(format.clj:323)
      	at honeysql.format$eval29103$fn__29104$G__29094__29109.invoke(format.clj:90)
      	at honeysql.format$format.invokeStatic(format.clj:236)
      	at honeysql.format$format.doInvoke(format.clj:208)
      	at clojure.lang.RestFn.invoke(RestFn.java:410)
      	at puppetlabs.puppetdb.query_eng.engine$eval34121$sql_from_query__34126$fn__34127.invoke(engine.clj:1124)
      	at puppetlabs.puppetdb.query_eng.engine$eval34121$sql_from_query__34126.invoke(engine.clj:1121)
      	at puppetlabs.puppetdb.query_eng.engine$eval34254$fn__34256.invoke(engine.clj:1139)
      	at puppetlabs.puppetdb.query_eng.engine$eval34156$fn__34157$G__34147__34162.invoke(engine.clj:1130)
      	at puppetlabs.puppetdb.query_eng.engine$plan__GT_sql.invokeStatic(engine.clj:1258)
      	at puppetlabs.puppetdb.query_eng.engine$plan__GT_sql.invoke(engine.clj:1255)
      	at puppetlabs.puppetdb.query_eng.engine$compile_user_query__GT_sql.invokeStatic(engine.clj:2344)
      	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.query_eng$eval35379$produce_streaming_body__35384$fn__35385$fn__35388.invoke(query_eng.clj:193)
      	at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__28868$fn__28869.invoke(jdbc.clj:483)
      	at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:628)
      	at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:598)
      	at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__28868.invoke(jdbc.clj:482)
      	at puppetlabs.puppetdb.jdbc$eval28842$retry_sql_STAR___28847$fn__28848$fn__28849.invoke(jdbc.clj:454)
      	at puppetlabs.puppetdb.jdbc$eval28842$retry_sql_STAR___28847$fn__28848.invoke(jdbc.clj:453)
      	at puppetlabs.puppetdb.jdbc$eval28842$retry_sql_STAR___28847.invoke(jdbc.clj:444)
      	at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn.invokeStatic(jdbc.clj:480)
      	at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn.invoke(jdbc.clj:469)
      	at puppetlabs.puppetdb.query_eng$eval35379$produce_streaming_body__35384$fn__35385.invoke(query_eng.clj:189)
      	at puppetlabs.puppetdb.query_eng$eval35379$produce_streaming_body__35384.invoke(query_eng.clj:175)
      	at puppetlabs.puppetdb.http.query$query_handler$fn__38744.invoke(query.clj:377)
      	at clojure.core$comp$fn__4727.invoke(core.clj:2460)
      	at clojure.core$comp$fn__4727.invoke(core.clj:2460)
      	at compojure.response$eval22857$fn__22858.invoke(response.clj:33)
      	at compojure.response$eval22812$fn__22813$G__22803__22820.invoke(response.clj:6)
      	at puppetlabs.puppetdb.http.handlers$eval39273$node_routes__39278$fn__39279$fn__39280.invoke(handlers.clj:309)
      	at puppetlabs.puppetdb.http.query$extract_query$fn__38730.invoke(query.clj:311)
      	at bidi.ring$eval36625$fn__36626.invoke(ring.clj:20)
      	at bidi.ring$eval36604$fn__36605$G__36595__36614.invoke(ring.clj:12)
      	at puppetlabs.puppetdb.middleware$eval37916$make_pdb_handler__37925$fn__37928$fn__37930.invoke(middleware.clj:336)
      	at puppetlabs.puppetdb.middleware$wrap_with_illegal_argument_catch$fn__37811.invoke(middleware.clj:99)
      	at puppetlabs.puppetdb.middleware$verify_accepts_content_type$fn__37815.invoke(middleware.clj:114)
      	at puppetlabs.puppetdb.middleware$verify_content_type$fn__37827.invoke(middleware.clj:147)
      	at puppetlabs.puppetdb.middleware$wrap_with_metrics$fn__37843$fn__37852.invoke(middleware.clj:239)
      	at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__35456$fn__35457$fn__35458.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__35456$fn__35457.invoke(metrics.clj:14)
      	at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__35456$fn__35457$fn__35458.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__35456$fn__35457.invoke(metrics.clj:14)
      	at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__35456$fn__35457$fn__35458.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__35456$fn__35457.invoke(metrics.clj:14)
      	at puppetlabs.puppetdb.utils.metrics$multitime_BANG__STAR_$fn__35456$fn__35457$fn__35458.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__35456$fn__35457.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__37843.invoke(middleware.clj:238)
      	at puppetlabs.puppetdb.middleware$wrap_with_globals$fn__37806.invoke(middleware.clj:93)
      	at puppetlabs.puppetdb.http.server$build_app$fn__39459.invoke(server.clj:74)
      	at compojure.core$routing$fn__24407.invoke(core.clj:151)
      	at clojure.core$some.invokeStatic(core.clj:2592)
      	at clojure.core$some.invoke(core.clj:2583)
      	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__50264.invoke(pdb_routing.clj:35)
      	at compojure.core$if_context$fn__24469.invoke(core.clj:218)
      	at compojure.core$routing$fn__24407.invoke(core.clj:151)
      	at clojure.core$some.invokeStatic(core.clj:2592)
      	at clojure.core$some.invoke(core.clj:2583)
      	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:648)
      	at clojure.core$apply.invoke(core.clj:641)
      	at compojure.core$routes$fn__24411.invoke(core.clj:156)
      	at compojure.core$routing$fn__24407.invoke(core.clj:151)
      	at clojure.core$some.invokeStatic(core.clj:2592)
      	at clojure.core$some.invoke(core.clj:2583)
      	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__50275.invoke(pdb_routing.clj:62)
      	at compojure.core$if_context$fn__24469.invoke(core.clj:218)
      	at puppetlabs.pe_puppetdb_extensions.sync.pe_routing$wrap_cert_and_token_authn$fn__52846.invoke(pe_routing.clj:64)
      	at puppetlabs.rbac_client.middleware.authentication$wrap_token_access_STAR_$fn__52716.invoke(authentication.clj:73)
      	at ring.middleware.params$wrap_params$fn__35556.invoke(params.clj:64)
      	at puppetlabs.puppetdb.middleware$wrap_with_certificate_cn$fn__37796.invoke(middleware.clj:75)
      	at puppetlabs.puppetdb.middleware$wrap_with_default_body$fn__37801.invoke(middleware.clj:82)
      	at puppetlabs.puppetdb.middleware$wrap_with_debug_logging$fn__37779.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__44592.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.RequestLogHandler.handle(RequestLogHandler.java:56)
      	at com.puppetlabs.trapperkeeper.services.webserver.jetty9.utils.MDCRequestLogHandler.handle(MDCRequestLogHandler.java:36)
      	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.QueuedThreadPool.runJob(QueuedThreadPool.java:762)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)
      	at java.lang.Thread.run(Thread.java:748)
      

      Related queries

      Similar queries that search for a non-null fact match return the expected responses:

      [root@pe-201817-master centos]# curl -sX GET http://localhost:8080/pdb/query/v4/nodes --data-urlencode 'query=["=", ["fact", "id"], "toot"]' | python -m json.tool
       
      []
       
      [root@pe-201817-master centos]# curl -sX GET http://localhost:8080/pdb/query/v4/nodes --data-urlencode 'query=["=", ["fact", "id"], "root"]' | python -m json.tool
       
      [
          {
              "cached_catalog_status": "not_used",
              "catalog_environment": null,
              "catalog_timestamp": null,
              "certname": "pe-201817-master.platform9.puppet.net",
              "deactivated": null,
              "expired": null,
              "facts_environment": "production",
              "facts_timestamp": "2019-03-13T20:05:12.348Z",
              "latest_report_corrective_change": false,
              "latest_report_hash": "47ed1c9acbc4e63b7548e018ee266abc2affdbe9",
              "latest_report_job_id": null,
              "latest_report_noop": false,
              "latest_report_noop_pending": false,
              "latest_report_status": "failed",
              "report_environment": "production",
              "report_timestamp": "2019-03-13T20:05:14.836Z"
          }
      ]
      

      Queries that search for a "null?" match on non-facts also return the expected responses:

      [root@pe-201817-master centos]# curl -sX GET http://localhost:8080/pdb/query/v4/nodes --data-urlencode 'query=["null?", "certname", true]' | python -m json.tool
       
      []
       
      [root@pe-201817-master centos]# curl -sX GET http://localhost:8080/pdb/query/v4/nodes --data-urlencode 'query=["null?", "certname", false]' | python -m json.tool
       
      [
          {
              "cached_catalog_status": "not_used",
              "catalog_environment": null,
              "catalog_timestamp": null,
              "certname": "pe-201817-master.platform9.puppet.net",
              "deactivated": null,
              "expired": null,
              "facts_environment": "production",
              "facts_timestamp": "2019-03-13T20:05:12.348Z",
              "latest_report_corrective_change": false,
              "latest_report_hash": "47ed1c9acbc4e63b7548e018ee266abc2affdbe9",
              "latest_report_job_id": null,
              "latest_report_noop": false,
              "latest_report_noop_pending": false,
              "latest_report_status": "failed",
              "report_environment": "production",
              "report_timestamp": "2019-03-13T20:05:14.836Z"
          }
      ]
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              garrett.guillotte Garrett Guillotte
              Votes:
              2 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:

                  Zendesk Support