Issues ****** APScheduler =========== If you check the log files e.g. ``~/repo/uwsgi/log/www.hatherleigh.info-scheduler-logger.log`` and see the scheduler looping, always *Adding job tentatively*, then there is probably an import error with your jobs e.g ``schedule_this_function_does_not_exist`` does not exist in ``crm.tasks``:: scheduler.add_job( "crm.tasks:schedule_this_function_does_not_exist", Ember JS ======== .. tip:: If Ember repeats the API call many times, then it may be because the view is not returning as many records as expected. ``ember-changeset-validations`` ------------------------------- The import for validations does not work if you use curly brackets (``{``, ``}``):: import { ContactValidations } from "../../validations/contact" Don't use curly brackets e.g:: import ContactValidations from "../../validations/contact" Add On ------ If you have a template in an (Embroider) add-on and it isn't displaying correctly, then try copying it to your project. You will see errors in the console, which are not displayed when the ``hbs`` file is in the add-on. You can move it back when all of the issues are resolved. Data ---- ``Unknown bucket`` from ``this.store.query``:: Assertion Failed: Unknown bucket undefined Your filter is probably an *Object* rather than an ID:: filter["contactId"] = this.args.contact // should be filter["contactId"] = this.args.contact.id Embroider --------- e.g:: webpack 5.75.0 compiled with 3 errors in 6233 ms Build Error (PackagerRunner) in modifiers/did-insert.js Module not found: Error: Can't resolve '../../../../app/ember-kb-core/ember-kb-core/node_modules/.pnpm/@ember+render-modifiers@2.0.4_7qtfvpmlucc5lcdjv3atxad67a/node_modules/@ember/render-modifiers/modifiers/did-insert' in '$TMPDIR/embroider/351288/project/my-project/front/modifiers/did-insert.js' Stack Trace and Error Report: /tmp/error.dump.fa33a5f885f8c20b6328bf67fb2f9032.log To solve the issue, I did:: rm -rf /tmp/embroider/ .. note:: I got this idea from reading https://github.com/embroider-build/embroider/issues/1116 but it didn't solve the issue. ``rootURL`` We were using ``rootURL`` in ``config/environment.js`` to load assets from the correct URL on the server (see ``dist/index.html``). When using Embroider, we also need to update the webpack configuration for ``publicAssetURL`` in ``ember-cli-build.js`` e.g:: packagerOptions: { // publicAssetURL is used similarly to Ember CLI's asset fingerprint prepend option. publicAssetURL: "/task/", For more information, see https://github.com/ef4/ember-auto-import/blob/main/docs/upgrade-guide-2.0.md#publicasseturl Ember Data ---------- I had an issue with Ember Data adapters. For more information, :ref:`ember-data-adapter` setRouteName ------------ I had this error message when trying to use a route from an addon:: route._setRouteName is not a function The error was in my route file (``addon/routes/workflow-delete.js``). I defined a ``Controller`` where I should have defined a ``Route``! Flowable ======== Data Types ========== Our workflow has a ``total`` variable with a value of ``1481.47``. Calling the ``form-data`` REST API (e.g. ``/service/form/form-data?taskId=93``) throws the following exception:: { "exception": "java.lang.Double cannot be cast to java.lang.String", "message": "Internal server error" } I am not casting the value to a string, so I think Activiti is storing the data internally as a ``Double``. .. note:: I have no idea why Activiti cannot cast a ``Double`` to a ``String`` Solution -------- I am using the ``double`` data type in the workflow, and it is accepted without any problem. Comparisons are working as long as both data types are a ``double`` e.g: .. code-block:: xml Issue #2 -------- I am now getting:: "java.lang.Integer cannot be cast to java.lang.String" Is this because my invoice number is a whole number, but is mapped to a string? Gateway ------- If your exclusive gateway is not behaving, check the following: 1. Check you are using a gateway. This example task does not use a gateway, so (I don't think) the engine knows which route to take next: .. image:: ./misc/bpm-gateway-not.png :scale: 60 Here is the same example task which has the required *exclusive* gateway: .. image:: ./misc/bpm-gateway.png :scale: 60 2. Check the gateway has a *Default flow* .. image:: ./misc/bpm-gateway-default-flow.png :scale: 60 In the XML file, the default gateway will look like this: .. code-block:: xml default="sid-54E01C76-51EC-4460-867B-017E84910394" .. tip:: If the default flow is empty, then I don't think the gateway works properly. Group ----- I was trying to set a group in the workflow:: activiti:candidateGroups="${hrGroupPk}" And kept getting the *Expression did not resolve to a string or collection of strings* exception thrown:: ERROR org.activiti.engine.impl.interceptor.CommandContext - Error while closing command context org.activiti.engine.ActivitiIllegalArgumentException: Expression did not resolve to a string or collection of strings To solve the issue, the group ID must be converted to a string: .. code-block:: python # replace this # result = self.group # with: result = str(self.group.pk) Here is the diff: https://gitlab.com/kb/workflow/commit/fe4816adaf2d1e5194666356b01c538ee6def6cb Lock ---- In ``/var/log/tomcat9/catalina.0000-00-00.log`` when restarting Tomcat:: liquibase.exception.LockException: Could not acquire change log lock. Currently locked by ... From `Flowable forum - Liquibase changeLogLock`... To resolve the issue, check the following tables in the Flowable database:: act_app_databasechangeloglock act_cmmn_databasechangeloglock act_co_databasechangeloglock act_dmn_databasechangeloglock act_fo_databasechangeloglock flw_ev_databasechangeloglock If you find a locked record e.g:: select * from flw_ev_databasechangeloglock; id | locked | lockgranted | lockedby ----+--------+-------------------------+----------------------- 1 | t | 2020-08-16 21:58:45.296 | UKAZU1S213 (10.3.3.4) .. warning:: From the link above, Clear the locks only if there is no upgrade running. The question is why Flowable crashed!? Then you can clear the lock:: UPDATE flw_ev_databasechangeloglock SET LOCKED=FALSE, LOCKGRANTED=null, LOCKEDBY=null where ID=1; Alfresco ======== Warning ref CPU usage above 90%:: sudo /opt/alfresco-community/libreoffice/scripts/libreoffice_ctl.sh stop sudo /opt/alfresco-community/libreoffice/scripts/libreoffice_ctl.sh start From `soffice.bin using 100% of CPU`_ APM === APM didn't upgrade until I ran the Salt state. It is also worth checking the `release notes`_. Celery ====== AMQP ---- .. note:: We use RabbitMQ (AMQP) when we deploy to Windows servers. If you find Celery wants to use AMQP (``amqp/transport.py``, ``Connection refused``), then check you created ``celery.py`` in your ``project`` (or ``example_appname``) folder, and that your ``__init__.py`` contains ``from .celery import app as celery_app``. For more information, see :doc:`celery` and :ref:`windows_celery` on Windows No such transport ----------------- Running a Django management command on Windows:: File "C:\inetpub\wwwroot\my-site\venv\lib\site-packages\kombu\transport\__init__.py", line 90, in resolve_transport raise KeyError('No such transport: {0}'.format(transport)) KeyError: 'No such transport: ' The ``set_env_test.bat`` command had the Celery URL in double quotes:: SET CELERY_BROKER_URL="amqp://guest:guest@localhost:5672//" To fix the issue, I removed the double quotes:: SET CELERY_BROKER_URL=amqp://guest:guest@localhost:5672// Not Running Tasks ----------------- If you find Celery is not running tasks, try the following: Open *Task Manager* on Windows and check you have a single instance of ``celery.exe`` running. I don't know why (or even if) multiple instances cause a problem, but a single instance has got us processing tasks again. If your task is in an app, check you are `Using the @shared_task decorator`_ .. _issues_celery_windows_service: Stalled ------- If your application stops / stall on a ``delay``, then ``redis`` might not be running:: transaction.on_commit( lambda: update_contact_index.delay(self.object.pk) ) I have no idea how long the timeout is... but it never returned for me! Windows Service --------------- We have a Windows Service for Waitress and Dramatiq. If they are failing, start by reviewing the Dramatiq_ notes below... Then try the following: I solved the problem (several times) by copying ``python37.dll`` from:: \kb\Python37\ to:: C:\Windows\System32\ To see an error message, try running:: \kb\Python38\Lib\site-packages\win32\pythonservice.exe -debug "KB-Software-Dramatiq" \kb\Python38\Lib\site-packages\win32\pythonservice.exe -debug "KB-Software-Waitress" .. note:: This is the code which is run by ``HandleCommandLine`` in ``win32serviceutil.py``. I used this to find the ``"pywintypes35.dll" is missing from your computer`` message which I fixed by running the next step in these notes. Try installing ``pywin32-228.win-amd64-py3.7.exe`` as a global package using the installer. The installer runs a script called ``pywin32_postinstall.py`` which copies DLL files to the correct locations. .. note:: Running ``pip install pypiwin32==219`` doesn't seem to run the ``pywin32_postinstall.py`` script, so the service cannot find the DLL files that it needs! Try running it manually using the globally installed python. To debug the service start-up, add ``ipdb`` to the code and then run:: python celery_service_worker.py debug cron ==== If a cron script in ``/etc/cron.d`` has a ``.`` in the file name, then it will not run! (`configs with dots in file name not working in /etc/cron.d`_) devpi ===== Certificate ----------- Firewall If you get 404 errors when attempting to create a certificate using HTTP validation and LetsEncrypt, then check your Firewall. It might not allow incoming connections to port 80 from the LetsEncrypt servers. To workaround the issue, use :doc:`detail/ssl-letsencrypt-dns` to generate the certificate. python 2 I was getting SSL ``certificate verify failed`` errors when using ``devpi`` (which uses ``httpie`` and ``requests``). To solve the issue, use ``devpi`` with a python 3 virtual environment (not python 2). Could not find a version that satisfies the requirement ------------------------------------------------------- I was trying to install Django 3.0.5 and kept getting this error:: Could not find a version that satisfies the requirement django==3.0.5 (from -r requirements/base.txt (line 10)) (from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, ... 2.2.3, 2.2.4, 2.2.5, 2.2.6, 2.2.7, 2.2.8, 2.2.9, 2.2.10, 2.2.11, 2.2.12) ERROR: No matching distribution found for ... Version 3.0.5 was not listed in the versions. I updated ``devpi`` thinking there was a problem with our PyPI server, but it didn't help. We were running Python 3.5.2 on our CI server. The *Django 3.0 release notes* says: Django 3.0 supports Python 3.6, 3.7, and 3.8. We highly recommend and only officially support the latest release of each series. The Django 2.2.x series is the last to support Python 3.5. To solve the issue, I upgrade the Docker container to use Ubuntu 18.04 (`Upgrade container to Ubuntu 18.04`_). Index ----- If you have a local PyPI server, and you **do not** want to use it, then comment out ``index-url`` in:: ~/.pip/pip.conf Killed ------ My ``devpi-server --import`` was not completing and finishing with a ``Killed`` message. To solve this issue, increase the available memory on the server. I increased from 1GB to 2GB and the import completed successfully. Django ====== CORS ---- To solve this issue, we replaced:: router = routers.DefaultRouter() with:: router = routers.DefaultRouter(trailing_slash=False) The solution was prompted by this Stackoverflow article, `React to django CORS issue`_ Sometimes it happens because of the url pattern. Please check the url pattern whether it requires a slash at the end or not. Try using 'login' instead of 'login/' current transaction is aborted ------------------------------ If you get this error when running unit tests:: django.db.utils.InternalError: current transaction is aborted, commands ignored until end of transaction block Add ``--create-db`` to recreate the database. Thank you to `Django+Postgres: "current transaction is aborted`_ for the solution. Remove the ``admin`` app ------------------------ If you get this error:: django.urls.exceptions.NoReverseMatch: 'admin' is not a registered namespace Then you may need to replace the ``staff_member_required`` decorator... For more information, see :doc:`dev-django-view`... Testing File Field ------------------ :: django.core.exceptions.SuspiciousFileOperation: The joined path (/2020/06/None-example.dat) is located outside of the base path component (/home/patrick/dev/app/record/media-private) To solve this issue, load the test file from the ``MEDIA_ROOT`` folder e.g:: from django.conf import settings from pathlib import Path file_name = Path( settings.BASE_DIR, settings.MEDIA_ROOT, "data", "1-2-3.doc" ) record = Record.objects.create_record( "testing", user, file_name=file_name ) Django Compressor ----------------- I had an issue where relative images in css files were not being found e.g:: url(../img/logo-fill.png) Django Compressor is supposed to convert relative URLs to absolute e.g:: url('https://hatherleigh-info-test.s3.amazonaws.com/dash/img/logo-fill.png?ae4f8b52c99c') The ``compress`` management command creates a manifest file listing the files it creates. On the web server this can be found in:: ./web_static/CACHE/manifest.json On Amazon S3 it is in the ``CACHE`` folder. You can look at the manifest files to find the name of the generated CSS file and look in this file to see if the relative URLs are converted to absolute. You can use the browser developer tools to see which CSS file is being used. To solve the issue, I checked the generated CSS file and the links were not relative. I then ran ``compress`` and checked the generated CSS file again and the links were absolute. I re-started the Django project on the server and all was OK. .. tip:: I also uninstalled ``django-storages-redux`` and reinstalled the old version: (``git+https://github.com/pkimber/django-storages-py3.git@py3#egg=storages``) ... but I don't think that made a difference?! Migrations ---------- ``InvalidBasesError``:: django.db.migrations.exceptions.InvalidBasesError: Cannot resolve bases for [] This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth) in an app with no migrations; see https://docs.djangoproject.com/en/5.1/topics/migrations/#dependencies To solve the issue, create the ``migrations`` folder with an ``__init__.py`` file:: mkdir web/migrations touch web/migrations/__init__.py For more information, see `InvalidBasesError: Cannot resolve bases for []`_ Django REST Framework ===================== I created a serializer (using the ``serializers.Serializer`` class), but was getting the following error message when calling ``serializer.data``:: :: TypeError: 'method' object is not iterable The issue was caused by a ``_data`` method which I put in the serializer. This clashes with an attribute of the ``Serializer`` class!!! To solve the issue, I renamed the ``_data`` method to ``_workflow_data``. Django REST Framework JSON API ============================== Could not satisfy the request Accept header ------------------------------------------- Trying to upload from Ember to Django using ``ember-file-upload``, https://ember-file-upload.pages.dev/ .. code-block:: json { "errors": [ { "detail": "Could not satisfy the request Accept header.", "status": "406", "source": { "pointer": "/data" }, "code": "not_acceptable" } ] } To solve the issue, add ``accepts: ["application/vnd.api+json"]`` .. code-block:: js const response = await file.upload( uploadUrl, { accepts: ["application/vnd.api+json"], headers: headers } ); unexpected keyword argument 'partial' ------------------------------------- :: update() got an unexpected keyword argument 'partial' To resolve this issue, change the ``update`` parameters in the view set:: # from # def update(self, request, pk=None): # to def update(self, request, *args, **kwargs): .. _docker-system-prune: Docker ====== To cleanup Docker containers, run the following as ``root``:: docker system prune -a .. tip:: May be safer to run it without the ``-a`` as I had to reinstall ``gitlab-runner``! Dramatiq ======== Service not Running ------------------- Try running ``dramatiq`` from the command line:: c: cd \kb\navigator-connector set_env_variables.bat c:\kb\navigator-connector\venv\Scripts\dramatiq.exe We had an *Access is denied* message when running ``dramatiq.exe``. The resolution was to add a *local exclusion for that folder within Microsoft Defender*. For more information, see https://www.kbsoftware.co.uk/crm/ticket/5668/ ``gevent`` ---------- Compile fails and I can't find the required dependencies:: x86_64-linux-gnu-gcc: error: src/gevent/libev/corecext.c: No such file or directory x86_64-linux-gnu-gcc: fatal error: no input files compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 To fix this issue, upgrade ``pip`` so it can install wheels. ``pika`` -------- Error:: ModuleNotFoundError: No module named 'pika' Make sure ``django_dramatiq`` is first in your list of ``THIRD_PARTY_APPS``. If this doesn't help, then make sure you have configured your settings files correctly for Dramatiq (don't forget ``dev_test.py``). For details, see :ref:`dramatiq_configure`. Dropbox ======= When testing the scripts:: No protocol specified !! (Qt:Fatal) QXcbConnection: Could not connect to display :0 To stop this error, use a headless connection i.e. ssh into the computer or use a separate console. This will still be an issue if you have a GUI and you ``sudo`` to a user who is *not* running a GUI. Backup ------ If the backup server runs out of space: 1. Lots of directories in ``/tmp`` called ``.dropbox-dist*`` (10Gb) 2. Backup folder for the site had lots of ``.sql`` files from presumably failed backup (3Gb) 3. Check the ``/home/web/tmp`` folder. Malcolm deleted this, which freed 1.8G of space! 4. Check the ``/home/web/temp/`` folder and track down large files:: du -sh * 5. You could also try (it didn't free any space for me):: rm -r /home/web/repo/files/dropbox//Dropbox/.dropbox.cache/* Duplicity ========= gio --- If you get this error:: No module named gio Then:: apt-get install python-gobject-2 Symbolic Links -------------- Duplicity does **NOT** backup symbolic links... or the contents of symbolic links. ElasticSearch ============= For version 6.x issues, see: 1. :ref:`elasticsearch_version_6` 2. APM_ Connection marked as dead ------------------------- Errors from the ElasticSearch client saying:: %s marked as dead for %s seconds The code can be seen here: https://github.com/rhec/pyelasticsearch/blob/master/pyelasticsearch/client.py#L241 My thought is that the ``pyelasticsearch`` client is timing out when the ``cron`` task re-indexes the data (there are lots of records, so I would expect this to take some time). The connections are pooled, and time-out, so the connection is marked as dead. To see if this is the problem (or not), I have added ``BATCH_SIZE`` and ``TIMEOUT`` to the settings:: HAYSTACK_CONNECTIONS = { 'default': { 'BATCH_SIZE': 100, 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', 'INDEX_NAME': '{}'.format(SITE_NAME), 'TIMEOUT': 60 * 5, 'URL': 'http://127.0.0.1:9200/', }, } For documentation on these settings: http://django-haystack.readthedocs.org/en/v2.1.0/settings.html The following signatures couldn't be verified --------------------------------------------- Trying to install the Salt state for Elastic:: ID: deb [signed-by=/etc/apt/keyrings/elasticsearch-keyring.gpg arch=amd64] https://artifacts.elastic.co/packages/8.x/apt stable main Failed to configure repo 'deb [signed-by=/etc/apt/keyrings/elasticsearch-keyring.gpg arch=amd64] https://artifacts.elastic.co/packages/8.x/apt stable main': W: GPG error: https://artifacts.elastic.co/packages/8.x/apt stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D27D666CD88E42B4 E: The repository 'https://artifacts.elastic.co/packages/8.x/apt stable InRelease' is not signed. To solve the issue, `Download and install the public signing key`_:: wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg Move the key to the location expected by the Salt state:: sudo mv /usr/share/keyrings/elasticsearch-keyring.gpg /etc/apt/keyrings/elasticsearch-keyring.gpg I then had to ``apt remove elasticsearch`` and then ``apt install elasticsearch`` before it would work. Re-apply the Salt state... .. tip:: I am sure it would be easy to update the Salt state, but I am feeling tired this evening. fabric ====== ``env`` is not set when you use ``run`` (with ``Connection``). To resolve the issue, add ``inline_ssh_env`` to the ``Connection`` constructor e.g:: with Connection(domain_deploy, user, inline_ssh_env=True) as ctx: ctx.run( "cd {site_folder} && {venv} {manage} {command}".format(**param), env=env, replace_env=True, echo=True, ) .. warning:: The ``inline_ssh_env`` functionality does not perform any shell escaping on your behalf! For more information, see `fabric, Connection, __init__`_ git === git clone fails with "fatal: Out of memory, malloc failed" error ---------------------------------------------------------------- To install the Salt master on a Linux server with less resources, I created a swap file:: df -v swapon --show free fallocate -l 1G /swapfile ls -lh /swapfile sudo chmod 600 /swapfile ls -lh /swapfile mkswap /swapfile swapon /swapfile swapon --show free .. tip:: Instructions from `How To Add Swap Space on Ubuntu 16.04`_ GitLab ====== CI -- If you find Continuous Integration (CI) is running tests from other apps, then check the project ``setup.cfg`` file to make sure ``src`` is included in the ``norecursedirs`` section. For details, see :ref:`continuous_integration`. Push an existing Git repository ------------------------------- If following the instructions to push an existing project to a new repo e.g:: cd existing_repo git remote rename origin old-origin git remote add origin git@gitlab.com:kb/simple-site.git git push -u origin --all git push -u origin --tags And you get ``remote rejected`` errors:: To gitlab.com:kb/simple-site.git ! [remote rejected] 5419-wagtail -> 5419-wagtail (pre-receive hook declined) ! [remote rejected] 5419-wagtail-tailwind-ui -> 5419-wagtail-tailwind-ui (pre-receive hook declined) ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@gitlab.com:kb/simple-site.git' Update your permissions in the *Members* section to *Maintainer*. Google ====== Captcha - Not Submitted ----------------------- The Captcha data is not submitted when using JavaScript to ``POST`` a form e.g::
Reset Password To solve the issue (*field is required*), just use a ``button`` e.g:: Captcha - ``element.form.submit is not a function`` --------------------------------------------------- ``recaptchaFormSubmit``:: TypeError: element.form.submit is not a function To solve the issue, remove ``name="submit"`` from the ``button`` e.g::