clojure.lang.ExceptionInfo: Input to munge-result-row does not match schema: [(named {:avg disallowed-key} row)]

JIRA | Dylan Ratcliffe | 11 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    When using any of the PQL functions it is very easy to get PuppetDB to throw a {{Input to munge-result-row does not match schema}} error. When this is thrown PuppetDB never responds to the query, causing it to timeout. All queries below are calling the root endpoint i.e. {{http://(master):8080/pdb/query/v4?query=(query)}} e.g. The following query: {code} fact_contents[value] { path ~> ["memory",".*","available_bytes"] } {code} Returns the following data as expected: {code} [ { "value": 693243904 }, { "value": 693268480 }, { "value": 3061817344 } ] {code} However if I try to average these numbers: {code} fact_contents[avg(value)] { path ~> ["memory",".*","available_bytes"] } {code} I get the following exception in the PuppetDB logs: {code} clojure.lang.ExceptionInfo: Input to munge-result-row does not match schema: [(named {:avg disallowed-key} row)] at puppetlabs.puppetdb.query.fact_contents$eval26634$munge_result_row__26639.invoke(fact_contents.clj:22) ~[na:na] at clojure.core$map$fn__4785.invoke(core.clj:2646) ~[puppetdb.jar:na] at clojure.lang.LazySeq.sval(LazySeq.java:40) ~[puppetdb.jar:na] at clojure.lang.LazySeq.seq(LazySeq.java:49) ~[puppetdb.jar:na] at clojure.lang.LazySeq.first(LazySeq.java:71) ~[puppetdb.jar:na] at clojure.lang.RT.first(RT.java:667) ~[puppetdb.jar:na] at clojure.core$first__4339.invokeStatic(core.clj:55) ~[puppetdb.jar:na] at clojure.core$first__4339.invoke(core.clj:55) ~[puppetdb.jar:na] at puppetlabs.puppetdb.query_eng$eval26835$produce_streaming_body__26840$fn__26841$fn__26845$fn__26847$fn__26848$fn__26851.invoke(query_eng.clj:182) ~[na:na] at clojure.core$comp$fn__4727.invoke(core.clj:2460) ~[puppetdb.jar:na] at clojure.core$comp$fn__4727.invoke(core.clj:2460) ~[puppetdb.jar:na] at puppetlabs.puppetdb.jdbc$with_query_results_cursor$fn__21251.invoke(jdbc.clj:344) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:620) ~[na:na] at clojure.java.jdbc$db_transaction_STAR_.doInvoke(jdbc.clj:568) ~[na:na] at clojure.lang.RestFn.invoke(RestFn.java:425) ~[puppetdb.jar:na] at puppetlabs.puppetdb.jdbc$with_query_results_cursor.invokeStatic(jdbc.clj:337) ~[na:na] at puppetlabs.puppetdb.jdbc$with_query_results_cursor.invoke(jdbc.clj:326) ~[na:na] at puppetlabs.puppetdb.query_eng$eval26835$produce_streaming_body__26840$fn__26841$fn__26845$fn__26847$fn__26848.invoke(query_eng.clj:179) ~[na:na] at puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__21230$fn__21231.invoke(jdbc.clj:306) ~[na:na] {code} However if I try seemingly the exact same thing using a different entity: {code} facts[value] { certname ~ "agent" and name = "uptime_seconds"} {code} Returns: {code} [ { "value": 20844 }, { "value": 20757 } ] {code} And If I try to average it: {code} facts[avg(value)] { certname ~ "agent" and name = "uptime_seconds"} {code} It works: {code} [ { "avg": 20800.5 } ] {code} This seems weird given that the input data for each function seems to be in the exact same format. This not only applicable to the avg() function. In situations where it fails, it will fail regardless of the function that is used.

    JIRA | 11 months ago | Dylan Ratcliffe
    clojure.lang.ExceptionInfo: Input to munge-result-row does not match schema: [(named {:avg disallowed-key} row)]

    Root Cause Analysis

    1. clojure.lang.ExceptionInfo

      Input to munge-result-row does not match schema: [(named {:avg disallowed-key} row)]

      at puppetlabs.puppetdb.query.fact_contents$eval26634$munge_result_row__26639.invoke()
    2. puppetlabs.puppetdb.query
      fact_contents$eval26634$munge_result_row__26639.invoke
      1. puppetlabs.puppetdb.query.fact_contents$eval26634$munge_result_row__26639.invoke(fact_contents.clj:22)[na:na]
      1 frame
    3. Clojure
      core$first__4339.invoke
      1. clojure.core$map$fn__4785.invoke(core.clj:2646)[puppetdb.jar:na]
      2. clojure.lang.LazySeq.sval(LazySeq.java:40)[puppetdb.jar:na]
      3. clojure.lang.LazySeq.seq(LazySeq.java:49)[puppetdb.jar:na]
      4. clojure.lang.LazySeq.first(LazySeq.java:71)[puppetdb.jar:na]
      5. clojure.lang.RT.first(RT.java:667)[puppetdb.jar:na]
      6. clojure.core$first__4339.invokeStatic(core.clj:55)[puppetdb.jar:na]
      7. clojure.core$first__4339.invoke(core.clj:55)[puppetdb.jar:na]
      7 frames
    4. puppetlabs.puppetdb
      query_eng$eval26835$produce_streaming_body__26840$fn__26841$fn__26845$fn__26847$fn__26848$fn__26851.invoke
      1. puppetlabs.puppetdb.query_eng$eval26835$produce_streaming_body__26840$fn__26841$fn__26845$fn__26847$fn__26848$fn__26851.invoke(query_eng.clj:182)[na:na]
      1 frame
    5. Clojure
      core$comp$fn__4727.invoke
      1. clojure.core$comp$fn__4727.invoke(core.clj:2460)[puppetdb.jar:na]
      2. clojure.core$comp$fn__4727.invoke(core.clj:2460)[puppetdb.jar:na]
      2 frames
    6. puppetlabs.puppetdb
      jdbc$with_query_results_cursor$fn__21251.invoke
      1. puppetlabs.puppetdb.jdbc$with_query_results_cursor$fn__21251.invoke(jdbc.clj:344)[na:na]
      1 frame
    7. Clojure
      RestFn.invoke
      1. clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:620)[na:na]
      2. clojure.java.jdbc$db_transaction_STAR_.doInvoke(jdbc.clj:568)[na:na]
      3. clojure.lang.RestFn.invoke(RestFn.java:425)[puppetdb.jar:na]
      3 frames
    8. puppetlabs.puppetdb
      jdbc$with_transacted_connection_fn$fn__21230$fn__21231.invoke
      1. puppetlabs.puppetdb.jdbc$with_query_results_cursor.invokeStatic(jdbc.clj:337)[na:na]
      2. puppetlabs.puppetdb.jdbc$with_query_results_cursor.invoke(jdbc.clj:326)[na:na]
      3. puppetlabs.puppetdb.query_eng$eval26835$produce_streaming_body__26840$fn__26841$fn__26845$fn__26847$fn__26848.invoke(query_eng.clj:179)[na:na]
      4. puppetlabs.puppetdb.jdbc$with_transacted_connection_fn$fn__21230$fn__21231.invoke(jdbc.clj:306)[na:na]
      4 frames