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

Underscore separated field name is required in one context dash separated in another

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PDB 3.0.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      PuppetDB 2015-04-22

      Description

      Depending on context (on other parameters specified in a PDB request) PuppetDB sometimes requires an underscore separated field name other times a dash separated field name in the query parameter. See the following example queries and the corresponding responses returned by PuppetDB:

      • underscore separated field name - report_receive_time - required but dash separated name - report-receive-time - specified

        curl -i -gG http://localhost:8080/v4/aggregate-event-counts --data-urlencode 'query=["<","report-receive-time","2015-04-03T21:48:24Z"]' --data-urlencode 'summarize_by=containing_class' 
        HTTP/1.1 400 Bad Request
        Date: Fri, 03 Apr 2015 23:24:21 GMT
        Content-Length: 369
        Server: Jetty(9.2.10.v20150310)
         
        'report-receive-time' is not a queryable object for events, known queryable objects are ["certname","configuration_version","containing_class","containment_path","environment","file","latest_report?","line","message","new_value","old_value","property","report","report_receive_time","resource_title","resource_type","run_end_time","run_start_time","status","timestamp"]
        

      • underscore separated field name - report_receive_time - required and specified

        curl -i -gG http://localhost:8080/v4/aggregate-event-counts --data-urlencode 'query=["<","report_receive_time","2015-04-03T21:48:24Z"]' --data-urlencode 'summarize_by=containing_class' 
        HTTP/1.1 200 OK
        Date: Fri, 03 Apr 2015 23:26:40 GMT
        Content-Type: application/json; charset=utf-8
        Content-Length: 84
        Server: Jetty(9.2.10.v20150310)
         
        {
          "successes" : 1,
          "failures" : 5,
          "noops" : 1,
          "skips" : 2,
          "total" : 6
        }
        

      • dash separated name - report-receive-time - required but underscore separated field name - report_receive_time - specified

        curl -i -gG http://localhost:8080/v4/aggregate-event-counts --data-urlencode 'distinct_resources=true' --data-urlencode 'distinct_start_time=2015-04-02T21:48:24Z' --data-urlencode 'distinct_end_time=2015-04-03T21:48:24Z' --data-urlencode 'query=["<","report_receive_time","2015-04-03T21:48:24Z"]' --data-urlencode 'summarize_by=containing_class' 
        HTTP/1.1 400 Bad Request
        Date: Fri, 03 Apr 2015 23:31:04 GMT
        Content-Length: 76
        Server: Jetty(9.2.10.v20150310)
         
        < operator does not support object 'report_receive_time' for resource events
        

      • dash separated name - report-receive-time - required and specified

        curl -i -gG http://localhost:8080/v4/aggregate-event-counts --data-urlencode 'distinct_resources=true' --data-urlencode 'distinct_start_time=2015-04-02T21:48:24Z' --data-urlencode 'distinct_end_time=2015-04-03T21:48:24Z' --data-urlencode 'query=["<","report-receive-time","2015-04-03T21:48:24Z"]' --data-urlencode 'summarize_by=containing_class' 
        HTTP/1.1 200 OK
        Date: Fri, 03 Apr 2015 23:31:59 GMT
        Content-Type: application/json; charset=utf-8
        Content-Length: 84
        Server: Jetty(9.2.10.v20150310)
         
        {
          "successes" : 1,
          "failures" : 2,
          "noops" : 1,
          "skips" : 0,
          "total" : 4
        }
        

      Additional info:

      • apparently the difference is the use of the distinct_* parameters: when they are specified then the dash separated field name is required, otherwise the underscore separated field name is required
      • I did not investigate whether other field names besides the report_receive_time/report-receive-time are also affected

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                michal.ruzicka Michal Ruzicka
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: