Errors

Page content

Misc Errors and Solutions

Flask & sqlalchemy

(flask-tables-py3.10) user@host ../flask-tables> python create_fake_users.py 5
Traceback (most recent call last):
  File "/Users/stoege/git/mpr_2023Q1/flask-tables/create_fake_users.py", line 6, in <module>
    from bootstrap_table import User, db
  File "/Users/stoege/git/mpr_2023Q1/flask-tables/bootstrap_table.py", line 18, in <module>
    db.create_all()
  File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 868, in create_all
    self._call_for_binds(bind_key, "create_all")
  File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 839, in _call_for_binds
    engine = self.engines[key]
  File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/flask_sqlalchemy/extension.py", line 628, in engines
    app = current_app._get_current_object()  # type: ignore[attr-defined]
  File "/Users/stoege/git/mpr_2023Q1/flask-tables/.venv/lib/python3.10/site-packages/werkzeug/local.py", line 513, in _get_current_object
    raise RuntimeError(unbound_message) from None
RuntimeError: Working outside of application context.

This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.

Solution

https://stackoverflow.com/questions/34122949/working-outside-of-application-context-flask

-> Downgrade flask-sqlalchemy to 2.5.1

# Downgrade Flask Version
gsed -i 's/flask-sqlalchemy.*/flask-sqlalchemy = "~2.5.1"/' pyproject.toml

# Rebuild Lock
poetry lock

# Install Packages
poetry install

# run again
python create_fake_users.py 5

Gitlab on Vultr

Created a Gitlab Instance on Vultr for testing Reason. Seems all fine, except:

root@gitlab:~# apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu focal-security InRelease
Get:2 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
Err:2 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease
  The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
Fetched 23.3 kB in 2s (11.0 kB/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease: The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
W: Failed to fetch https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/focal/InRelease  The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
W: Some index files failed to download. They have been ignored, or old ones used instead.

Solution

curl -s https://packages.gitlab.com/gpg.key | apt-key add -
apt-get update
apt-get upgrade

Selfsigned Cert

gitlab has got a selfsigned cert on gitlab sever. like to change this.

Solution

cd /etc/gitlab/
cp gitlab.rb gitlab.rb.bak
sed -i 's/^external_url.*/external_url "https:\/\/gitlab.your.domain.net"/' gitlab.rb
sed -i "s/^# letsencrypt\['auto_renew'\].*/letsencrypt['auto_renew'] = true/" gitlab.rb
sed -i "s/^# letsencrypt\['contact_emails'\].*/letsencrypt['contact_emails'] = ['domains@your.domain.net']/" gitlab.rb
git diff gitlab.rb.*
gitlab-ctl reconfigure

Airflow Root Login

you have Airflow running on Docker and not root login ?

docker exec -u root -ti airflow-airflow-scheduler-1 bash

Solution then, you can install all the stuff you need and fix your problems

apt-get update
apt-get upgrade
apt-get install htop lsof tree procps tcpdump net-tools mlocate dnsutils
updatedb

cron & poetry

you wanna run a python script via poetry as cronjob and you get the following error:

# cronjob as root
* * * * * cd /path/to/your/script; poetry run mycode > out 2>&1

# error
Traceback (most recent call last):
  File "/usr/local/bin/poetry", line 5, in <module>
    from poetry.console.application import main
  File "/usr/local/lib/python3.9/site-packages/poetry/console/application.py", line 19, in <module>
    from poetry.__version__ import __version__
  File "/usr/local/lib/python3.9/site-packages/poetry/__version__.py", line 5, in <module>
    from poetry.utils._compat import metadata
  File "/usr/local/lib/python3.9/site-packages/poetry/utils/_compat.py", line 20, in <module>
    import importlib_metadata as metadata
  File "/usr/local/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 6, in <module>
    import zipp
ModuleNotFoundError: No module named 'zipp'

**Solution**
-> set HOME as the Virtual Env is located here
* * * * * export HOME=/root; cd /path/to/your/script; poetry run mycode > out 2>&1

gpg on OpenBSD 7.4

test1@puffy $ gpg --generate-key 
gpg (GnuPG) 2.4.3; Copyright (C) 2023 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Note: Use "gpg --full-generate-key" for a full featured key generation dialog.

GnuPG needs to construct a user ID to identify your key.

Real name: user1
Email address: user1@puffy205
You selected this USER-ID:
    "user1 <user1@puffy205>"

Change (N)ame, (E)mail, or (O)kay/(Q)uit? o
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: agent_genkey failed: Permission denied
Key generation failed: Permission denied

seems a permission error ?!? ktrace / kdump did not help. When i allow the User for doas (root), it seems working.

solution build the key in tmux (proper handling of ownership with terminal-related device file)

tmux
gpg --generate-key

hint

ls -l $(tty)
crw--w----  1 stoege  tty    5,   0 Jan  2 09:25 /dev/ttyp0

vs

tmux
ls -l $(tty)
crw--w----  1 test1  tty    5,   1 Jan  2 09:27 /dev/ttyp1

SQL Alchemy2 on OpenBSD 7.4 / 7.5 Beta

root@yourhost /tmp/guguseli# poetry add pydantic
Using version ^2.6.4 for pydantic

Updating dependencies
Resolving dependencies... (1.2s)

Package operations: 2 installs, 0 updates, 0 removals

  - Installing pydantic-core (2.16.3): Failed

  ChefInstallError

  Failed to install typing-extensions >=4.6.0,!=4.7.0, maturin>=1,<2.

  Output:
  Updating dependencies
  Resolving dependencies...

  Package operations: 3 installs, 0 updates, 0 removals

    - Installing tomli (2.0.1)
    - Installing maturin (1.5.1)
    - Installing typing-extensions (4.10.0)

    ChefBuildError

    Backend subprocess exited when trying to invoke build_wheel

    /tmp/tmp90xuiusw/.venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:83: SetuptoolsWarning: `install_requires` overwritten in `pyproject.toml` (dependencies)
      corresp(dist, value, root_dir)
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.openbsd-7.5-amd64-cpython-310
    creating build/lib.openbsd-7.5-amd64-cpython-310/maturin
    copying maturin/__init__.py -> build/lib.openbsd-7.5-amd64-cpython-310/maturin
    copying maturin/__main__.py -> build/lib.openbsd-7.5-amd64-cpython-310/maturin
    copying maturin/import_hook.py -> build/lib.openbsd-7.5-amd64-cpython-310/maturin
    running egg_info
    creating maturin.egg-info
    writing maturin.egg-info/PKG-INFO
    writing dependency_links to maturin.egg-info/dependency_links.txt
    writing requirements to maturin.egg-info/requires.txt
    writing top-level names to maturin.egg-info/top_level.txt
    writing manifest file 'maturin.egg-info/SOURCES.txt'
    reading manifest file 'maturin.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.json' under directory 'src/python_interpreter'
    writing manifest file 'maturin.egg-info/SOURCES.txt'
    running build_ext
    running build_rust
     Downloading crates ...
    error: failed to wait on curl `Multi`

    Caused by:
      Unrecoverable error in select/poll
    error: `cargo metadata --manifest-path Cargo.toml --format-version 1 --locked` failed with code 101
    -- Output captured from stdout:
root@yourhost # ulimit -n 1024
root@yourhost # poetry add pydantic
... here we are ...
pip debug --verbose

Any Comments ?

sha256: 544f583153ef22c57986f77c05e773d507c695bac36353a08c02e7ad4548704f