anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: voxpupuli/puppetboard
Issue: Setting GRAPH_FACTS causes a 500 error

**Describe the bug**

We set `GRAPH_FACTS = "architecture,puppetversion,osfamily"` in the config file. This seems to cause an error when loading node facts:

```
ERROR:puppetboard.core:Exception on /node/dc4.example.com/facts/json [GET]
Traceback (most recent call last):
  File "/srv/puppetboard/virtenv-puppetboard/lib64/python3.9/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/srv/puppetboard/virtenv-puppetboard/lib64/python3.9/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/srv/puppetboard/virtenv-puppetboard/lib64/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/srv/puppetboard/virtenv-puppetboard/lib64/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/srv/puppetboard/virtenv-puppetboard/lib64/python3.9/site-packages/puppetboard/views/facts.py", line 50, in fact_ajax
    if fact in app.config['GRAPH_FACTS'] and value is None and node is None:
TypeError: 'in <string>' requires string as left operand, not NoneType
```

**Puppetboard version**

4.3.0

**Environment and installation method**

* Rocky Linux 9.2 with Python 3.9.16 from the OS repositories
* installed with the Forge module v9.0.0 and using the PyPI package (default).


Changed files:
puppetboard/views/facts.py

diff --git a/puppetboard/views/facts.py b/puppetboard/views/facts.py
index 17525ca..6649071 100644
--- a/puppetboard/views/facts.py
+++ b/puppetboard/views/facts.py
@@ -47,7 +47,7 @@ def fact_ajax(env, node, fact, value):
     check_env(env, envs)
 
     render_graph = False
-    if fact in app.config['GRAPH_FACTS'] and value is None and node is None:
+    if fact is not None and fact in app.config['GRAPH_FACTS'] and value is None and node is None:
         render_graph = True
 
     query = AndOperator()
Repository: voxpupuli/puppetboard
Issue: Queries through the query tab do not work

CentOS 7.1
apache + mod_wsgi
puppetboard v0.1.1 installed via pip
puppetdb v3.1.0

Everything else currently works fine in puppetboard.

When I attempt to run a simply query like:

```
["=", "certname", "test"]
```

 with the "Nodes" button selected and I get the following error:
"The request sent to PuppetDB was invalid. This is usually caused by using an unsupported operator."

I've enabled debugging in the logs, and I see the following from the error_log:

```
[Thu Dec 10 15:46:57.823332 2015] [:error] [pid 27609] DEBUG:pypuppetdb.api:_query called with endpoint: environments, path: None, query: None, limit: None, offset: None, summarize_by None, count_by None, count_filter: None
[Thu Dec 10 15:46:57.823466 2015] [:error] [pid 27609] DEBUG:pypuppetdb.api:_url called with endpoint: environments and path: None
[Thu Dec 10 15:46:57.832075 2015] [:error] [pid 27609] INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): mypuppetdb.host
[Thu Dec 10 15:46:57.836359 2015] [:error] [pid 27609] DEBUG:requests.packages.urllib3.connectionpool:"GET /pdb/query/v4/environments HTTP/1.1" 200 1053
```


Changed files:
puppetboard/app.py

diff --git a/puppetboard/app.py b/puppetboard/app.py
index ec7d65f..deedfc8 100644
--- a/puppetboard/app.py
+++ b/puppetboard/app.py
@@ -15,7 +15,6 @@ from flask import (
     Response, stream_with_context, redirect,
     request
     )
-from flask_wtf.csrf import CsrfProtect
 
 from pypuppetdb import connect
 
@@ -27,7 +26,6 @@ from puppetboard.utils import (
 
 
 app = Flask(__name__)
-CsrfProtect(app)
 
 app.config.from_object('puppetboard.default_settings')
 graph_facts = app.config['GRAPH_FACTS']
@@ -727,10 +725,10 @@ def query(env):
         select field in the environment block
     :type env: :obj:`string`
     """
-    envs = environments()
-    check_env(env, envs)
-
     if app.config['ENABLE_QUERY']:
+        envs = environments()
+        check_env(env, envs)
+
         form = QueryForm()
         if form.validate_on_submit():
             if form.query.data[0] == '[':
Repository: voxpupuli/puppetboard
Issue: Reports Pages: Event Counts are always filtering environments

The reports() and reports_node() event count queries are always filtering on the event's environment, even if All Environments (*) is selected. This will return bad results if the environment clause on the query is still active when it shouldn't.

A code example from the reports() function:

```
            query='["and",' \\
                '["=", "environment", "{0}"],' \\
                '["=", "certname", "{1}"],' \\
                '["=", "report", "{2}"]]'.format(
                    env,
                    report.node,
                    report.hash_),
```


Changed files:
puppetboard/app.py

diff --git a/puppetboard/app.py b/puppetboard/app.py
index 113eaf8..2fc10b2 100644
--- a/puppetboard/app.py
+++ b/puppetboard/app.py
@@ -416,14 +416,22 @@ def reports(env, page):
         abort(404)
 
     for report in reports_events:
-        counts = get_or_abort(puppetdb.event_counts,
-            query='["and",' \\
+        if env == '*':
+            event_count_query = '["and",' \\
+                '["=", "certname", "{0}"],' \\
+                '["=", "report", "{1}"]]'.format(
+                    report.node,
+                    report.hash_)
+        else:
+            event_count_query = '["and",' \\
                 '["=", "environment", "{0}"],' \\
                 '["=", "certname", "{1}"],' \\
                 '["=", "report", "{2}"]]'.format(
                     env,
                     report.node,
-                    report.hash_),
+                    report.hash_)
+        counts = get_or_abort(puppetdb.event_counts,
+            query=event_count_query,
             summarize_by="certname")
         try:
             report_event_counts[report.hash_] = counts[0]
@@ -483,11 +491,22 @@ def reports_node(env, node_name, page):
         abort(404)
 
     for report in reports_events:
-        counts = get_or_abort(puppetdb.event_counts,
-            query='["and",' \\
+        if env == '*':
+            event_count_query = '["and",' \\
+                '["=", "certname", "{0}"],' \\
+                '["=", "report", "{1}"]]'.format(
+                    report.node,
+                    report.hash_)
+        else:
+            event_count_query = '["and",' \\
                 '["=", "environment", "{0}"],' \\
                 '["=", "certname", "{1}"],' \\
-                '["=", "report", "{2}"]]'.format(env, report.node, report.hash_),
+                '["=", "report", "{2}"]]'.format(
+                    env,
+                    report.node,
+                    report.hash_)
+        counts = get_or_abort(puppetdb.event_counts,
+            query=event_count_query,
             summarize_by="certname")
         try:
             report_event_counts[report.hash_] = counts[0]