Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Invalid format string error when starting the server on Windows #556

@protokoul

Description

@protokoul

Describe the issue

Hi. I am setting up the project locally on Windows. When I start the server, it returns an error stating ValueError: Invalid format string. Error screenshot pasted below

Image

Steps to Reproduce

Set up the project locally referring to these steps on Windows and run the command codegate serve

Operating System

Microsoft Windows (Intel)

IDE and Version

N/A

Extension and Version

N/A

Provider

Other

Model

N/A

Logs

Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "E:\github_forks\codegate-fork\venv\Scripts\codegate.exe_main
.py", line 4, in
from codegate.cli import main
File "E:\github_forks\codegate-fork\src\codegate\cli.py", line 20, in
from codegate.providers.copilot.provider import CopilotProvider
File "E:\github_forks\codegate-fork\src\codegate\providers\copilot_init
.py", line 1, in
from codegate.providers.copilot.provider import CopilotProvider
File "E:\github_forks\codegate-fork\src\codegate\providers\copilot\provider.py", line 26, in
setup_logging()
~~~~~~~~~~~~~^^
File "E:\github_forks\codegate-fork\src\codegate\codegate_logging.py", line 155, in setup_logging
logger.debug(
~~~~~~~~~~~~^
"Logging initialized",
^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
},
^^
)
^
File "E:\github_forks\codegate-fork\venv\Lib\site-packages\structlog_native.py", line 134, in meth
return self._proxy_to_logger(name, event, **kw)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "E:\github_forks\codegate-fork\venv\Lib\site-packages\structlog_base.py", line 214, in _proxy_to_logger
args, kw = self._process_event(method_name, event, event_kw)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\github_forks\codegate-fork\venv\Lib\site-packages\structlog_base.py", line 165, in _process_event
event_dict = proc(self._logger, method_name, event_dict)
File "E:\github_forks\codegate-fork\venv\Lib\site-packages\structlog\processors.py", line 490, in call
return self._stamper(event_dict)
~~~~~~~~~~~~~^^^^^^^^^^^^
File "E:\github_forks\codegate-fork\venv\Lib\site-packages\structlog\processors.py", line 551, in stamper_fmt
event_dict[key] = now().strftime(fmt)
~~~~~~~~~~~~~~^^^^^
ValueError: Invalid format string

Additional Context

The issue is due to '.%03dZ' in the custom datetime format "%Y-%m-%dT%H:%M:%S.%03dZ" used in the function setup_logging in src/codegate/codegate_logging.py.

This format gets passed to the function stamper_fmt() inside the class structlog.processors.TimeStamper. stamper_fmt() uses strftime() which works fine on Linux, but on Windows it returns an invalid format string error. Below is the result of using the same format in Ubuntu and Windows

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions