Skip to content

ZoneInfoNotFoundError: 'No time zone found with key UTC' due to missing tzdata package #62

@ahmed-arb

Description

@ahmed-arb

Description

The credentials service crashes with a ZoneInfoNotFoundError when handling requests because the tzdata Python package is not installed in the Docker image. This causes a 500 error on every request, including /admin.

Error

ModuleNotFoundError: No module named 'tzdata'

Which leads to:

zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key UTC'

The full chain is: Django's timezone context processor calls zoneinfo.ZoneInfo(settings.TIME_ZONE), which attempts to load timezone data via the tzdata package. Since the package is missing and the system tzdata files are apparently not available either, the lookup fails — even for UTC.

Steps to Reproduce

  1. Run credentials service via Tutor
  2. Navigate to any page (e.g. /admin)
  3. Observe HTTP 500 response

Environment

  • Python 3.11.9
  • Django (via Open edX credentials)
  • Tutor v20+

Workaround

A Tutor plugin that installs tzdata into the credentials image:

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "credentials-dockerfile-post-python-requirements",
        "RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install tzdata",
    )
)

Suggested Fix

Add tzdata to the Python requirements for the credentials Docker image. On Python 3.9+ (especially on minimal/Alpine-style images that lack system timezone data), the tzdata package is the expected fallback for zoneinfo and should be an explicit dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions