Skip to content

Function Scheduler failing due to incorrect timestamp format #255

Description

@BennetVellaExient
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/firebase_functions/scheduler_fn.py", line 102, in on_schedule_wrapped
    schedule_time = _dt.datetime.strptime(
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "/layers/google.python.runtime/python/lib/python3.12/_strptime.py", line 653, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/layers/google.python.runtime/python/lib/python3.12/_strptime.py", line 432, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2025-10-17T16:50:00.510855-07:00' does not match format '%Y-%m-%dT%H:%M:%S%z'"

This started happening over the weekend with no changes / alterations to our workers. From the internal logic it appears to be sourced at:

    def on_schedule_decorator(func: _C):

        @_functools.wraps(func)
        def on_schedule_wrapped(request: _Request) -> _Response:
            schedule_time: _dt.datetime
            schedule_time_str = request.headers.get(
                "X-CloudScheduler-ScheduleTime")
            if schedule_time_str is None:
                schedule_time = _dt.datetime.utcnow()
            else:
                schedule_time = _dt.datetime.strptime(
                    schedule_time_str,
                    "%Y-%m-%dT%H:%M:%S%z",
                )

So I'm suspecting that the following request.headers.get("X-CloudScheduler-ScheduleTime") has changed? Upgrading the sdk version is likely to be a major endeavour, what's the simplest solution here?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions