Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

puppetboard fails to start because module 'flask.json' has no attribute 'JSONEncoder' #888

Open
gizmo15 opened this issue Jul 6, 2023 · 0 comments
Labels

Comments

@gizmo15
Copy link

gizmo15 commented Jul 6, 2023

Hi,

Describe the bug

Puppetboard start with uwsgi :
from __future__ import absolute_import
import os

# Uncomment to enable logging
# import logging
# logging.basicConfig(filename='/var/log/puppetboard/puppetboard.log', level=logging.INFO)

# Indicate where to find the configuration file
os.environ['PUPPETBOARD_SETTINGS'] = '/usr/local/etc/puppetboard/settings.py'

from puppetboard.app import app as application

but in the log :

*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x82e732140
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145824 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
  File "/var/www/html/puppetboard/wsgi.py", line 6, in <module>
    from puppetboard.app import app as application
  File "/usr/local/lib/python3.9/site-packages/puppetboard/app.py", line 27, in <module>
    import puppetboard.views.query  # noqa: F401
  File "/usr/local/lib/python3.9/site-packages/puppetboard/views/query.py", line 9, in <module>
    from puppetboard.forms import ENABLED_QUERY_ENDPOINTS, QueryForm
  File "/usr/local/lib/python3.9/site-packages/puppetboard/forms.py", line 3, in <module>
    from flask_wtf import FlaskForm
  File "/usr/local/lib/python3.9/site-packages/flask_wtf/__init__.py", line 3, in <module>
    from .recaptcha import *
  File "/usr/local/lib/python3.9/site-packages/flask_wtf/recaptcha/__init__.py", line 2, in <module>
    from .fields import *
  File "/usr/local/lib/python3.9/site-packages/flask_wtf/recaptcha/fields.py", line 3, in <module>
    from . import widgets
  File "/usr/local/lib/python3.9/site-packages/flask_wtf/recaptcha/widgets.py", line 4, in <module>
    JSONEncoder = json.JSONEncoder
AttributeError: module 'flask.json' has no attribute 'JSONEncoder'
unable to load app 0 (mountpoint='') (callable not found or import error)

If i change the file /usr/local/lib/python3.9/site-packages/flask_wtf/recaptcha/widgets.py from :

from flask import Markup, current_app, json
from werkzeug.urls import url_encode

To :

from flask import Markup, current_app
from werkzeug.urls import url_encode
import json

It's OK :

*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x82d122140
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145824 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
INFO:puppetboard.utils:PuppetDB version: 7.13.0
WARNING:puppetboard.utils:Leaving SECRET_KEY set to a default value WILL cause issues when the app is restarted or has more than 1 replica (f.e. uWSGI workers, k8s replicas etc.) and some features (in particular: queries) are used.
Please set SECRET_KEY to your own value, the same for all app replicas.
This will be REQUIRED starting with Puppetboard 5.x which will NOT contain the default value anymore.
Please see https://github.com/voxpupuli/puppetboard/issues/721 for more info.
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x82d122140 pid: 3507 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3507)
spawned uWSGI worker 1 (pid: 3516, cores: 1)

Puppetboard version

4.2.6

pkg info | grep puppetboard
py39-puppetboard-4.2.6         Web interface to PuppetDB

Environment and installation method
On FreeBSD 13.2-RELEASE with python 3.9.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant