Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 744151 - dev-db/pgadmin4-4.17-r1 with dev-python/flask-security-3.4.4 - pgAdmin4: ImportError: cannot import name '_render_json' from 'flask_security.views' (/usr/lib/python3.7/site-packages/flask_security/views.py)
Summary: dev-db/pgadmin4-4.17-r1 with dev-python/flask-security-3.4.4 - pgAdmin4: Impo...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: PgSQL Bugs
URL:
Whiteboard:
Keywords:
Depends on: 755260
Blocks:
  Show dependency tree
 
Reported: 2020-09-22 19:46 UTC by George Tarasov
Modified: 2020-12-25 03:17 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Goran's patch (pgadmin4-4.17-flask-security-3.3.0-render-json.patch,1.03 KB, patch)
2020-09-24 20:23 UTC, George Tarasov
Details | Diff
ebuild patch (pgadmin4-4.17-r1.patch,468 bytes, patch)
2020-09-24 20:24 UTC, George Tarasov
Details | Diff
ebuild patch (pgadmin4-4.17-r1.patch,468 bytes, patch)
2020-09-24 20:27 UTC, George Tarasov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description George Tarasov 2020-09-22 19:46:10 UTC
pgAdmin4 crashes on the start up with the Fatal Error "The application server could not be contacted"
and the following messages in the log files


~ $ cat ~/.pgAdmin4.startup.log 
22.09.2020 21:51:22 Checking for system tray...
22.09.2020 21:51:22 Starting pgAdmin4 server...
22.09.2020 21:51:22 Creating server object, port:35437, key:9f07a6d9-bcc4-4951-8574-790b5b76464f, logfile:/home/george/.pgAdmin4.14570597673959349582.log
22.09.2020 21:51:22 Python Path: /usr/lib/python3.7/site-packages
22.09.2020 21:51:22 Python Home: 
22.09.2020 21:51:22 Initializing Python...
22.09.2020 21:51:22 Python initialized.
22.09.2020 21:51:22 Adding new additional path elements
22.09.2020 21:51:22 Redirecting stderr...
22.09.2020 21:51:22 stderr redirected successfully.
22.09.2020 21:51:22 Initializing server...
22.09.2020 21:51:22 Webapp Path: /usr/share/pgadmin4/web/pgAdmin4.py
22.09.2020 21:51:22 Server initialized.
22.09.2020 21:51:22 Starting Server Thread...
22.09.2020 21:51:22 Open the application code and run it.
22.09.2020 21:51:22 Set the port number, key and force SERVER_MODE off
22.09.2020 21:51:22 PyRun_SimpleFile launching application server...
22.09.2020 21:51:23 Application Server URL: http://127.0.0.1:35437/?key=9f07a6d9-bcc4-4951-8574-790b5b76464f
22.09.2020 21:51:23 The server should be up, we'll attempt to connect and get a response. Ping the server
22.09.2020 21:51:23 Failed to launch the application server, server thread exiting.
22.09.2020 21:52:53 Attempt to connect one more time in case of a long network timeout while looping

~ $ cat ~/.pgAdmin4.14570597673959349582.log 
Traceback (most recent call last):
  File "/usr/share/pgadmin4/web/pgAdmin4.py", line 109, in <module>
    app = create_app()
  File "/usr/share/pgadmin4/web/pgadmin/__init__.py", line 608, in create_app
    for module in app.find_submodules('pgadmin'):
  File "/usr/share/pgadmin4/web/pgadmin/__init__.py", line 73, in find_submodules
    module = import_module(module_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/share/pgadmin4/web/pgadmin/browser/__init__.py", line 32, in <module>
    from flask_security.views import _security, _commit, _render_json, _ctx
ImportError: cannot import name '_render_json' from 'flask_security.views' (/usr/lib/python3.7/site-packages/flask_security/views.py)

Reproducible: Always

Steps to Reproduce:
1. run pgAdmin4 from Desktop Menu or from console /usr/bin/pgAdming4
2.
3.
Actual Results:  
Fatal Error "The application server could not be contacted."

Expected Results:  
Should start pgAdmin4 server and open new tab in browser with the appropriate content.

~ $ emerge --info
Portage 3.0.4 (python 3.7.8-final-0, default/linux/amd64/17.0/desktop, gcc-9.3.0, glibc-2.31-r6, 5.4.60-gentoo x86_64)
=================================================================
System uname: Linux-5.4.60-gentoo-x86_64-Intel-R-_Core-TM-_i5-3230M_CPU_@_2.60GHz-with-gentoo-2.7
KiB Mem:     5649344 total,    143508 free
KiB Swap:    6291452 total,   6230268 free
Timestamp of repository gentoo: Sun, 20 Sep 2020 00:45:01 +0000
Head commit of repository gentoo: 1960b98f396dfe80288eb64f043de2adfd10f300
sh bash 5.0_p18
ld GNU ld (Gentoo 2.34 p6) 2.34.0
ccache version 3.7.11 [enabled]
app-shells/bash:          5.0_p18::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18-r2::gentoo, 3.7.8-r2::gentoo, 3.8.5::gentoo
dev-util/ccache:          3.7.11::gentoo
dev-util/cmake:           3.16.5::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.18::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.34-r2::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r6::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.ru.gentoo.org
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1

local-overlay
    location: /usr/local/portage
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=corei7 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.4/ext-active/ /etc/php/cgi-php7.4/ext-active/ /etc/php/cli-php7.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=corei7 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs ccache config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles/"
LANG="ru_RU.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli crypt cups dbus dri dts dvd dvdr elogind emboss encode exif flac fortran gdbm gif gpm gtk gui iconv icu ipv6 jpeg lcms libglvnd libnotify libtirpc mad mng mp3 mp4 mpeg multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt5 readline sdl seccomp smp spell split-usr ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb vim-syntax vorbis wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="libinput synaptics" KERNEL="linux" L10N="en ru" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python3_7 python3_8" RUBY_TARGETS="ruby25 ruby26" USERLAND="GNU" VIDEO_CARDS="intel nvidia" XFCE_PLUGINS="battery brightness power trash" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Goran Muzevic 2020-09-24 10:00:26 UTC
I have the same issue with starting pgAdmin4. I found the similar (although not identical) issue on OpenSuse forum https://forums.opensuse.org/showthread.php/539523-pgAdmin4-startet-nicht-mehr?p=2930160#post2930160

pgAdmin4 uses calss to the _render_json that doesn't exist in my version of the the /usr/lib/python3.7/site-packages/flask_security/views.py file. The value in pgAdmin4 is _render_json and the views.py has the value default_render_json.

I managed to get my pgAdmin4 working by adding the "default" prefix to the _render_json on two places:

diff /usr/share/pgadmin4/web/pgadmin/browser/__init__.py /tmp/new.py 
32c32
< from flask_security.views import _security, _commit, _render_json, _ctx
---
> from flask_security.views import _security, _commit, default_render_json, _ctx
948c948
<             return _render_json(form)
---
>             return default_render_json(form)

I hope this helps.
Comment 2 George Tarasov 2020-09-24 20:23:30 UTC
Created attachment 662314 [details, diff]
Goran's patch
Comment 3 George Tarasov 2020-09-24 20:24:17 UTC
Created attachment 662317 [details, diff]
ebuild patch
Comment 4 George Tarasov 2020-09-24 20:24:49 UTC
Worked for me! Thanks!

While the new versions of pgadmin4 have not yet been stabilized, i'm attaching the following patches for temporary error workaround.

pgadmin4-4.17-flask-security-3.3.0-render-json.patch: Goran's patch
pgadmin4-4.17-r1.patch: ebuild patch
Comment 5 George Tarasov 2020-09-24 20:27:35 UTC
Created attachment 662320 [details, diff]
ebuild patch
Comment 6 Aaron W. Swenson gentoo-dev 2020-09-26 10:46:50 UTC
Does the issue persist with 4.26?
Comment 7 George Tarasov 2020-09-27 08:33:14 UTC
(In reply to Aaron W. Swenson from comment #6)
> Does the issue persist with 4.26?

No! 
It works as expected.
Comment 8 jannis 2020-10-04 17:26:30 UTC
I experienced the same and I can confirm that upgrading to pgadmin4-4.26 fixed the issue. Could you stabilize it (along with the dependencies)? Thanks!
Comment 9 Aaron W. Swenson gentoo-dev 2020-11-18 12:09:22 UTC
(In reply to George Tarasov from comment #7)
> (In reply to Aaron W. Swenson from comment #6)
> > Does the issue persist with 4.26?
> 
> No! 
> It works as expected.

(In reply to jannis from comment #8)
> I experienced the same and I can confirm that upgrading to pgadmin4-4.26
> fixed the issue. Could you stabilize it (along with the dependencies)?
> Thanks!

Thanks for follow up!
Comment 10 Larry the Git Cow gentoo-dev 2020-12-25 03:17:57 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f997bdc5009d9b7b78b57ddf1494867268eaca13

commit f997bdc5009d9b7b78b57ddf1494867268eaca13
Author:     Aaron W. Swenson <titanofold@gentoo.org>
AuthorDate: 2020-12-25 03:16:08 +0000
Commit:     Aaron W. Swenson <titanofold@gentoo.org>
CommitDate: 2020-12-25 03:16:08 +0000

    dev-db/pgadmin4: Cleanup
    
    Closes: https://bugs.gentoo.org/735014
    Closes: https://bugs.gentoo.org/744151
    Signed-off-by: Aaron W. Swenson <titanofold@gentoo.org>

 dev-db/pgadmin4/Manifest                           |   3 -
 .../pgadmin4/files/pgadmin4-4.17-python-3.8.patch  |  12 --
 dev-db/pgadmin4/pgadmin4-4.17-r1.ebuild            | 120 -------------------
 dev-db/pgadmin4/pgadmin4-4.25.ebuild               | 124 --------------------
 dev-db/pgadmin4/pgadmin4-4.28.ebuild               | 130 ---------------------
 5 files changed, 389 deletions(-)