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.

[Bug]: Copilot pipeline errors out when body is empty #395

@ptelang

Description

@ptelang

Describe the issue

2024-12-17T15:47:21.3dZ [error    ] Pipeline processing error: Expecting value: line 1 column 1 (char 0) module=pipeline pathname=/Users/ptelang/Documents/stacklok-projects/codegate/src/codegate/providers/copilot/pipeline.py
2024-12-17T15:47:21.3dZ [error    ] ERROR OCCURRED                 module=pipeline pathname=/Users/ptelang/Documents/stacklok-projects/codegate/src/codegate/providers/copilot/pipeline.py
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/ptelang/Documents/stacklok-projects/codegate/src/codegate/providers/copilot/pipeline.py:7 │
│ 2 in process_body                                                                                │
│                                                                                                  │
│    69 │   async def process_body(self, headers: list[str], body: bytes) -> Tuple[bytes, Pipeli   │
│    70 │   │   """Common processing logic for all strategies"""                                   │
│    71 │   │   try:                                                                               │
│ ❱  72 │   │   │   normalized_body = self.normalizer.normalize(body)                              │
│    73 │   │   │                                                                                  │
│    74 │   │   │   headers_dict = {}                                                              │
│    75 │   │   │   for header in headers:                                                         │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │    body = b''                                                                                │ │
│ │       e = JSONDecodeError('Expecting value: line 1 column 1 (char 0)')                       │ │
│ │ headers = [                                                                                  │ │
│ │           │   'Host: api.enterprise.githubcopilot.com',                                      │ │
│ │           │   'Connection: keep-alive',                                                      │ │
│ │           │   'Content-Length: 4581',                                                        │ │
│ │           │   'authorization: Bearer                                                         │ │
│ │           tid=5a7a34f1094fcf8541e5e99866e20edc;ol=5eb723af34fdc3808d'+238,                   │ │
│ │           │   'content-type: application/json',                                              │ │
│ │           │   'copilot-integration-id: vscode-chat',                                         │ │
│ │           │   'editor-plugin-version: copilot-chat/0.23.1',                                  │ │
│ │           │   'editor-version: vscode/1.96.0',                                               │ │
│ │           │   'openai-intent: conversation-panel',                                           │ │
│ │           │   'openai-organization: github-copilot',                                         │ │
│ │           │   ... +9                                                                         │ │
│ │           ]                                                                                  │ │
│ │    self = <codegate.providers.copilot.pipeline.CopilotChatPipeline object at 0x109e0c980>    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /Users/ptelang/Documents/stacklok-projects/codegate/src/codegate/providers/copilot/pipeline.py:1 │
│ 52 in normalize                                                                                  │
│                                                                                                  │
│   149 │   """                                                                                    │
│   150 │                                                                                          │
│   151 │   def normalize(self, body: bytes) -> ChatCompletionRequest:                             │
│ ❱ 152 │   │   json_body = json.loads(body)                                                       │
│   153 │   │   return ChatCompletionRequest(**json_body)                                          │
│   154 │                                                                                          │
│   155 │   def denormalize(self, request_from_pipeline: ChatCompletionRequest) -> bytes:          │
│                                                                                                  │
│ ╭───────────────────────────────────────── locals ─────────────────────────────────────────╮     │
│ │ body = b''                                                                               │     │
│ │ self = <codegate.providers.copilot.pipeline.CopilotChatNormalizer object at 0x109e0cad0> │     │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯     │
│                                                                                                  │
│ /opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3. │
│ 13/json/__init__.py:346 in loads                                                                 │
│                                                                                                  │
│   343 │   if (cls is None and object_hook is None and                                            │
│   344 │   │   │   parse_int is None and parse_float is None and                                  │
│   345 │   │   │   parse_constant is None and object_pairs_hook is None and not kw):              │
│ ❱ 346 │   │   return _default_decoder.decode(s)                                                  │
│   347 │   if cls is None:                                                                        │
│   348 │   │   cls = JSONDecoder                                                                  │
│   349 │   if object_hook is not None:                                                            │
│                                                                                                  │
│ ╭───────── locals ─────────╮                                                                     │
│ │               cls = None │                                                                     │
│ │                kw = {}   │                                                                     │
│ │       object_hook = None │                                                                     │
│ │ object_pairs_hook = None │                                                                     │
│ │    parse_constant = None │                                                                     │
│ │       parse_float = None │                                                                     │
│ │         parse_int = None │                                                                     │
│ │                 s = ''   │                                                                     │
│ ╰──────────────────────────╯                                                                     │
│                                                                                                  │
│ /opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3. │
│ 13/json/decoder.py:344 in decode                                                                 │
│                                                                                                  │
│   341 │   │   containing a JSON document).                                                       │
│   342 │   │                                                                                      │
│   343 │   │   """                                                                                │
│ ❱ 344 │   │   obj, end = self.raw_decode(s, idx=_w(s, 0).end())                                  │
│   345 │   │   end = _w(s, end).end()                                                             │
│   346 │   │   if end != len(s):                                                                  │
│   347 │   │   │   raise JSONDecodeError("Extra data", s, end)                                    │
│                                                                                                  │
│ ╭────────────────────────────── locals ──────────────────────────────╮                           │
│ │   _w = <built-in method match of re.Pattern object at 0x100d4cba0> │                           │
│ │    s = ''                                                          │                           │
│ │ self = <json.decoder.JSONDecoder object at 0x100d1b380>            │                           │
│ ╰────────────────────────────────────────────────────────────────────╯                           │
│                                                                                                  │
│ /opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3. │
│ 13/json/decoder.py:362 in raw_decode                                                             │
│                                                                                                  │
│   359 │   │   try:                                                                               │
│   360 │   │   │   obj, end = self.scan_once(s, idx)                                              │
│   361 │   │   except StopIteration as err:                                                       │
│ ❱ 362 │   │   │   raise JSONDecodeError("Expecting value", s, err.value) from None               │
│   363 │   │   return obj, end                                                                    │
│   364                                                                                            │
│                                                                                                  │
│ ╭──────────────────────── locals ─────────────────────────╮                                      │
│ │  idx = 0                                                │                                      │
│ │    s = ''                                               │                                      │
│ │ self = <json.decoder.JSONDecoder object at 0x100d1b380> │                                      │
│ ╰─────────────────────────────────────────────────────────╯                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Steps to Reproduce

No response

Operating System

None

IDE and Version

No response

Extension and Version

No response

Provider

None

Model

No response

Logs

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions