镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Python: Bug: Semantic Kernel breaks FASTAPI Debugging Launch config #8420

Closed

Description

Describe the bug
After adding the semantic kernel import to a python project running on FASTAPI from the VSCode Debugger this breaks pymeta (which is a required dependency). This prevents all debugging for our project. Seems there is a conflict between VSCode debugger and semantic kernel

To Reproduce
Steps to reproduce the behavior:

  1. Add Semantic Kernel as a python dependency
  2. Add 'import semantic_kernel' to a file
  3. Launch FastAPI using uvicorn (-m uvicorn api-hosting-lambda.src.app:app --reload --port 8002) from a launch config (see below)
  4. pymetic error

Exception has occurred: ParseError (note: full exception trace is shown but execution is paused at: _G_many_2)
(7, [('expected', 'letter or digit', None)])
File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 259, in _G_many_2 (Current frame)
_G_apply_1, lastError = self._apply(self.rule_letterOrDigit, "letterOrDigit", [])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 262, in rule_name
_G_many_3, lastError = self.many(_G_many_2)
File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 604, in _G_lookahead_2
_G_apply_1, lastError = self._apply(self.rule_name, "name", [])
File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 608, in rule_rule
_G_lookahead_3, lastError = self.lookahead(_G_lookahead_2)
File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 641, in _G_many_1
_G_apply_1, lastError = self._apply(self.rule_rule, "rule", [])
File "/pymeta_generated_code/pymeta_grammar__Grammar.py", line 644, in rule_grammar
_G_many_2, lastError = self.many(_G_many_1)
File "/home/ubuntu/GenerativeAIGit/koch-gpt/api-hosting-lambda/src/koch_ai.py", line 8, in
import semantic_kernel
File "/home/ubuntu/GenerativeAIGit/koch-gpt/api-hosting-lambda/src/conversations_handler.py", line 26, in
from koch_ai import KochAIChatBot
File "/home/ubuntu/GenerativeAIGit/koch-gpt/api-hosting-lambda/src/app.py", line 6, in
from conversations_handler import (
File "", line 1, in
pymeta.runtime.ParseError: (7, [('expected', 'letter or digit', None)])

Expected behavior
FastAPI should start up in the debugging session within VSCode

Screenshots
VSCode debugging Launch config
{
"name": "API Hosting on FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"api-hosting-lambda.src.app:app",
"--reload",
"--port",
"8002"
],
"cwd": "${workspaceFolder}/api-hosting-lambda/src",
"env": {
"JSON_LOGS": "0",
"LOG_LEVEL": "debug"
},
"jinja": true,
"justMyCode": true
}
Platform

  • OS: Ubuntu
  • IDE: VSCode
  • Language: Python
  • Source: FastAPI project

Additional context
Starting the app with the same command 'poetry run python -m uvicorn app:app --reload --port 8002' outside of a debugger works fine.

Activity

  1. changed the title [-]Bug: Semantic Kernel breaks FASTAPI Debugging Launch config[/-] [+]Python: Bug: Semantic Kernel breaks FASTAPI Debugging Launch config[/+] on Aug 29, 2024
  2. eavanvalkenburg commented on Sep 3, 2024

    @eavanvalkenburg
    Member

    Hi Nathan Smith (@sminath33)

    Not sure what is going on here, I just tried this and did not encounter issues, I have the following script, using fastapi[stardard] or fastapi[all] and SK (both just take the latest from pypi:

    from typing import Union
    
    import semantic_kernel
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    kernel = semantic_kernel.Kernel()
    
    
    @app.get("/")
    def read_root():
        return {"Hello": "World"}
    
    
    @app.get("/items/{item_id}")
    def read_item(item_id: int, q: Union[str, None] = None):
        return {"item_id": item_id, "q": q}

    and this starts, both with the same launch setup as you have, and with the newer debugpy launch command.

    {
        "name": "Python Debugger: FastAPI",
        "type": "debugpy",
        "request": "launch",
        "module": "uvicorn",
        "args": [
            "main:app",
            "--reload"
        ],
        "jinja": true
    },
  3. eavanvalkenburg commented on Sep 6, 2024

    @eavanvalkenburg
    Member

    Please reopen if you are still having issues!

  4. moved this from Bug to Sprint: Done in Semantic Kernelon Sep 6, 2024
  5. MahrRah commented on Jul 31, 2025

    @MahrRah

    I ran into the same issue and realized I had the User Uncaught exception option selected under Breakpoints. Once I unchecked it, I was able to debug as expected.

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

Metadata

Metadata

Labels

bugSomething isn't workingpythonPull requests for the Python Semantic Kernel

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions