Skip to content

[CLEANUP][SONAR][LOW]: Dead code - unused function json_default in llmchat_router.py #2372

@crivetimihai

Description

@crivetimihai

Severity: LOW
File: mcpgateway/routers/llmchat_router.py
Line: 805
Rule: python:S1144

Description

The nested function json_default is defined but never called anywhere in the code. It only appears in docstring examples.

Code

def json_default(obj):
    """
    Default JSON serializer helper for non-serializable Python objects.
    ...
    Examples:
        >>> json_default(Simple())  # Only in docstrings
    """
    if hasattr(obj, "model_dump"):
        return obj.model_dump()
    # ... etc

Impact

None - dead code that adds maintenance burden without providing value.

Suggested Fix

Either:

  1. Remove the unused function entirely
  2. Use it where JSON serialization is needed in the module

Metadata

Metadata

Assignees

Labels

COULDP3: Nice-to-have features with minimal impact if left out; included if time permitschoreLinting, formatting, dependency hygiene, or project maintenance choresgood first issueGood for newcomerspythonPython / backend development (FastAPI)sonarSonarQube code quality findings

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions