zulip / docker-zulip

Container configurations, images, and examples for Zulip.
https://zulip.com/
Apache License 2.0
550 stars 227 forks source link

Expecting "SOCIAL_AUTH_GITHUB_KEY", type "integer" #435

Closed shanzez closed 2 months ago

shanzez commented 3 months ago

I'm getting a failure on start-up when I set the following in my docker-compose.yml:

  zulip:
    image: "zulip/docker-zulip:8.3-0"
    restart: unless-stopped
    environment:
      DB_HOST: database
      DB_HOST_PORT: '5432'
      DB_USER: zulip
      SSL_CERTIFICATE_GENERATION: self-signed
      SETTING_MEMCACHED_LOCATION: "memcached:11211"
      SETTING_RABBITMQ_HOST: rabbitmq
      SETTING_REDIS_HOST: redis
      SECRETS_email_password: redacted
      SECRETS_rabbitmq_password: "redacted"
      SECRETS_postgres_password: "redacted"
      SECRETS_memcached_password: "redacted"
      SECRETS_redis_password: "redacted"
      SECRETS_secret_key: "redacted"
      SETTING_EXTERNAL_HOST: "redacted"
      SETTING_ZULIP_ADMINISTRATOR: "redacted"
      SETTING_EMAIL_HOST: "redacted"
      SETTING_EMAIL_HOST_USER: "redacted"
      SETTING_EMAIL_PORT: '587'
      SETTING_EMAIL_USE_SSL: 'False'
      SETTING_EMAIL_USE_TLS: 'True'
      SETTING_SOCIAL_AUTH_GITHUB_KEY: redacted
      SECRETS_social_auth_github_secret: redacted
      ZULIP_AUTH_BACKENDS: GitHubAuthBacken

It appears that it is the SETTING_SOCIAL_AUTH_GITHUB_KEY value. I see this in the docker log:

2024-04-02 17:26:39 Setting key "AUTHENTICATION_BACKENDS", type "array" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Adding authentication backend "GitHubAuthBacken".
2024-04-02 17:26:39 Authentication backend activation succeeded.
2024-04-02 17:26:39 Executing Zulip configuration ...
2024-04-02 17:26:39 Setting key "EMAIL_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "EMAIL_HOST_USER", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "EMAIL_PORT", type "integer" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "EMAIL_USE_SSL", type "bool" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "EMAIL_USE_TLS", type "bool" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "EXTERNAL_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "MEMCACHED_LOCATION", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "RABBITMQ_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "RABBITMQ_USER", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "RATE_LIMITING", type "bool" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "REDIS_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "REDIS_PORT", type "integer" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "SOCIAL_AUTH_GITHUB_KEY", type "integer" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Setting key "ZULIP_ADMINISTRATOR", type "string" in file "/etc/zulip/settings.py".
2024-04-02 17:26:39 Error in the Zulip configuration. Exiting.
2024-04-02 17:26:39 === Begin Initial Configuration Phase ===

I see, specifically:

Setting key "SOCIAL_AUTH_GITHUB_KEY", type "integer"

But my key (i.e. Client ID) is not an integer. In fact, I checked 3 of my Client IDs and they all appear to be hex.

Later on in the log I see:

2024-04-02 17:26:39 === Begin Initial Configuration Phase ===
2024-04-02 17:26:39 Preparing and linking the uploads folder ...
2024-04-02 17:26:39 Prepared and linked the uploads directory.
2024-04-02 17:26:39 Executing puppet configuration ...
2024-04-02 17:26:39 Traceback (most recent call last):
2024-04-02 17:26:39   File "/home/zulip/deployments/current/manage.py", line 145, in <module>
2024-04-02 17:26:39     log_management_command(sys.argv, settings.MANAGEMENT_LOG_PATH)
2024-04-02 17:26:39   File "/srv/zulip-venv-cache/988fc3c982c99797ff1f2f5d4b721b23afdec467/zulip-py3-venv/lib/python3.8/site-packages/django/conf/__init__.py", line 102, in __getattr__
2024-04-02 17:26:39     self._setup(name)
2024-04-02 17:26:39   File "/srv/zulip-venv-cache/988fc3c982c99797ff1f2f5d4b721b23afdec467/zulip-py3-venv/lib/python3.8/site-packages/django/conf/__init__.py", line 89, in _setup
2024-04-02 17:26:39     self._wrapped = Settings(settings_module)
2024-04-02 17:26:39   File "/srv/zulip-venv-cache/988fc3c982c99797ff1f2f5d4b721b23afdec467/zulip-py3-venv/lib/python3.8/site-packages/django/conf/__init__.py", line 217, in __init__
2024-04-02 17:26:39     mod = importlib.import_module(self.SETTINGS_MODULE)
2024-04-02 17:26:39   File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
2024-04-02 17:26:39     return _bootstrap._gcd_import(name[level:], package, level)
2024-04-02 17:26:39   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2024-04-02 17:26:39   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2024-04-02 17:26:39   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2024-04-02 17:26:39   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2024-04-02 17:26:39   File "<frozen importlib._bootstrap_external>", line 848, in exec_module
2024-04-02 17:26:39   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2024-04-02 17:26:39   File "/home/zulip/deployments/2024-03-20-04-24-34/zproject/settings.py", line 26, in <module>
2024-04-02 17:26:39     from .configured_settings import *  # noqa: F403 isort: skip
2024-04-02 17:26:39   File "/home/zulip/deployments/2024-03-20-04-24-34/zproject/configured_settings.py", line 10, in <module>
2024-04-02 17:26:39     from .default_settings import *  # noqa: F403 isort: skip
2024-04-02 17:26:39   File "/home/zulip/deployments/2024-03-20-04-24-34/zproject/default_settings.py", line 18, in <module>
2024-04-02 17:26:39     from .prod_settings import EXTERNAL_HOST, ZULIP_ADMINISTRATOR
2024-04-02 17:26:39   File "/home/zulip/deployments/2024-03-20-04-24-34/zproject/prod_settings.py", line 879
2024-04-02 17:26:39     SOCIAL_AUTH_GITHUB_KEY = <redacted>

I will look back in the code to see if this has always been this way or if it was a recent change. Right now, I don't have a way around it.

Of course if I remove that setting from my docker-compose.yml, it loads up just fine, so it does appear to be that one value (SOCIAL_AUTH_GITHUB_KEY) that is causing the failure to load.

shanzez commented 3 months ago

I think the issue is here: https://github.com/zulip/docker-zulip/blob/cd7692a7e6648e5a1da79fa71812428cd250b582/entrypoint.sh#L92

Not sure if that is the only place (since I'm not getting past that point). Something like this might work:

if [ -z "$TYPE" ]; then
    case "$2" in
        [Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Nn]one)
            TYPE="bool"
            ;;
        [1-9][0-9]*)
            if [[ "$2" =~ ^[1-9][0-9]*$ ]]; then
                TYPE="integer"
            else
                TYPE="string"
            fi
            ;;
        [\[\(]*[\]\)])
            TYPE="array"
            ;;
        *)
            TYPE="string"
            ;;
    esac
fi

The problem, I think, is that the case statement finds numbers in the value and classifies it as an integer. Since we cannot use regex in the case statement, I pushed it into that case item.

Example value in a docker-compose.yml: SETTING_SOCIAL_AUTH_GITHUB_KEY: 87ca9786478bf2d7021a

shanzez commented 3 months ago

It appears that this fix: https://github.com/zulip/docker-zulip/commit/0d72546a4cb183c985de6d96873ac5508cfd3ce3

is what is causing my issue. I understand it, but if I just revert back before this, I'll be working. I'll try it.

shanzez commented 3 months ago

Well, testing with 8.2-0 did resolve that issue.

Fixed:

2024-04-03 11:23:56 Adding authentication backend "GitHubAuthBacken".
2024-04-03 11:23:56 Authentication backend activation succeeded.
2024-04-03 11:23:56 Executing Zulip configuration ...
2024-04-03 11:23:56 Setting key "EMAIL_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "EMAIL_HOST_USER", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "EMAIL_PORT", type "integer" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "EMAIL_USE_SSL", type "bool" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "EMAIL_USE_TLS", type "bool" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "EXTERNAL_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "MEMCACHED_LOCATION", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "RABBITMQ_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "RABBITMQ_USER", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "RATE_LIMITING", type "bool" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "REDIS_HOST", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "REDIS_PORT", type "integer" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "SOCIAL_AUTH_GITHUB_KEY", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "SOCIAL_AUTH_GITHUB_ORG_NAME", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:56 Setting key "ZULIP_ADMINISTRATOR", type "string" in file "/etc/zulip/settings.py".
2024-04-03 11:23:59 Zulip configuration succeeded.
2024-04-03 11:23:59 Auto backup enabled.
.....
2024-04-03 11:24:36   Applying zerver.0496_alter_scheduledmessage_read_by_sender... OK
2024-04-03 11:24:37 Congratulations!  You have successfully configured your Zulip database.
2024-04-03 11:24:37 If you haven't already, you should configure email in /etc/zulip/settings.py.
2024-04-03 11:24:37 
2024-04-03 11:24:37 Next, run as the zulip user (use 'su zulip' if needed):
2024-04-03 11:24:37 
2024-04-03 11:24:37     /home/zulip/deployments/current/manage.py generate_realm_creation_link
2024-04-03 11:24:37 
2024-04-03 11:24:37 This generates a secure, single-use link that you you can use to set up 
2024-04-03 11:24:37 a Zulip organization from the convenience of your web browser.
2024-04-03 11:24:37 Zulip first start init sucessful.
2024-04-03 11:24:37 Migrating Zulip to new version ...
2024-04-03 11:24:39 Operations to perform:
2024-04-03 11:24:39   Apply all migrations: analytics, auth, confirmation, contenttypes, otp_static, otp_totp, phonenumber, sessions, social_django, zerver
2024-04-03 11:24:39 Running migrations:
2024-04-03 11:24:39   No migrations to apply.
2024-04-03 11:24:39 Zulip migration succeeded.
2024-04-03 11:24:39 Post setup scripts execution ...
2024-04-03 11:24:39 No post-setup.d folder found. Continuing.
2024-04-03 11:24:39 === End Bootstrap Phase ===
shanzez commented 3 months ago

This is definitely not intended:

      ZULIP_AUTH_BACKENDS: GitHubAuthBacken

(missing "d" at the end). Testing with this fixed.

Update: With that typo fixed, 8.2-0 works with the GITHUB values setup in the docker-compose.yml. I'm able to generate the new org link and setup the new org. So, anything beyond the issue I found with docker-zulip/entrypoint.sh was mine and can be ignored.

luckyraul commented 3 months ago

is it related to https://github.com/zulip/docker-zulip/issues/433 ?

shanzez commented 3 months ago

Yes, looks like the same. The PR is created should fix it. For now, the solution is to stick with 8.2-0.

alexmv commented 2 months ago

I've released 8.3-1 which resolves this. Sorry for the trouble!