makeplane/plane · error · AuthenticationException

5112

5112

Error message

GITEA_NOT_CONFIGURED

What it means

Raised in the Gitea OAuth provider (gitea.py:43) when any of GITEA_CLIENT_ID, GITEA_CLIENT_SECRET, or GITEA_HOST is falsy, OR (second raise, same code) when GITEA_HOST has no scheme or a scheme other than http/https. Code 5112. The scheme check deliberately reuses GITEA_NOT_CONFIGURED to avoid leaking validation details into OAuth redirect query params.

Source

Thrown at apps/api/plane/authentication/provider/oauth/gitea.py:43

        (GITEA_CLIENT_ID, GITEA_CLIENT_SECRET, GITEA_HOST) = get_configuration_value(
            [
                {
                    "key": "GITEA_CLIENT_ID",
                    "default": os.environ.get("GITEA_CLIENT_ID"),
                },
                {
                    "key": "GITEA_CLIENT_SECRET",
                    "default": os.environ.get("GITEA_CLIENT_SECRET"),
                },
                {
                    "key": "GITEA_HOST",
                    "default": os.environ.get("GITEA_HOST"),
                },
            ]
        )

        if not (GITEA_CLIENT_ID and GITEA_CLIENT_SECRET and GITEA_HOST):
            raise AuthenticationException(
                error_code=AUTHENTICATION_ERROR_CODES["GITEA_NOT_CONFIGURED"],
                error_message="GITEA_NOT_CONFIGURED",
            )

        # Enforce scheme and normalize trailing slash(es)
        parsed = urlparse(GITEA_HOST)
        if not parsed.scheme or parsed.scheme not in ("https", "http"):
            raise AuthenticationException(
                error_code=AUTHENTICATION_ERROR_CODES["GITEA_NOT_CONFIGURED"],
                error_message="GITEA_NOT_CONFIGURED",  # avoid leaking details to query params
            )
        GITEA_HOST = GITEA_HOST.rstrip("/")

        # Set URLs based on the host
        self.token_url = f"{GITEA_HOST}/login/oauth/access_token"
        self.userinfo_url = f"{GITEA_HOST}/api/v1/user"

        client_id = GITEA_CLIENT_ID

View on GitHub (pinned to 1c8a60f858)

Solutions

  1. Set GITEA_CLIENT_ID, GITEA_CLIENT_SECRET, and GITEA_HOST (with scheme) in instance config/env.
  2. Format GITEA_HOST as a full URL: 'https://gitea.example.com' (trailing slash is normalized away).
  3. If Gitea is not intended, remove the Gitea OAuth entry from the UI/discovery so users cannot select it.

Example fix

# before: GITEA_HOST=gitea.example.com  (no scheme) -> 5112
# GITEA_HOST=https://gitea.example.com
# GITEA_CLIENT_ID=<id>
# GITEA_CLIENT_SECRET=<secret>
# after: provider constructs and OAuth redirect proceeds
Defensive patterns

Strategy: validation

Validate before calling

import os
from urllib.parse import urlparse
from plane.license.utils.instance_value import get_configuration_value

def gitea_configured() -> bool:
    cid, secret, host = get_configuration_value([
        {'key': 'GITEA_CLIENT_ID', 'default': os.environ.get('GITEA_CLIENT_ID')},
        {'key': 'GITEA_CLIENT_SECRET', 'default': os.environ.get('GITEA_CLIENT_SECRET')},
        {'key': 'GITEA_HOST', 'default': os.environ.get('GITEA_HOST')},
    ])
    if not (cid and secret and host):
        return False
    p = urlparse(host)
    return p.scheme in ('http', 'https')

Try / catch

try:
    GiteaProvider(request, ...)
except AuthenticationException as e:
    if e.error_code == 5112:
        hide_gitea_option_or_show_config_guide()
    else:
        raise

Prevention

When it happens

Trigger: Constructing the Gitea OAuth provider reads the three GITEA_* values from instance config/env. If any is empty, AuthenticationException code 5112 is raised. Separately, urlparse(GITEA_HOST) must yield a scheme in (http, https) or the same error is raised. Hit by initiating or completing Gitea OAuth on a misconfigured instance.

Common situations: Gitea OAuth app not yet registered (missing client id/secret); GITEA_HOST entered as bare hostname without https:// (e.g. 'gitea.example.com' instead of 'https://gitea.example.com'); partial config after enabling Gitea integration.

Related errors


AI-assisted analysis of makeplane/plane@1c8a60f858 (2026-08-12). Data as JSON: /api/errors/7c517f3de04a5e8a. Report an issue: GitHub.