Skip to content

[Bug] is_valid_plugin uses malformed plugin_names.json path and can raise FileNotFoundError #245

@Flamki

Description

@Flamki

What problem are you trying to solve?

is_valid_plugin() in chatbot-core/api/tools/utils.py builds plugin_names.json path from os.path.abspath(__file__) as if it were a directory.

Current code:

list_plugin_names_path = os.path.join(os.path.abspath(__file__), "..", "..", "data", "raw", "plugin_names.json")

Because __file__ is a file path (.../utils.py), this resolves to an invalid location and raises FileNotFoundError.

Why this matters

search_plugin_docs(...) calls is_valid_plugin(...) when plugin_name is provided. A bad path here can break plugin-specific retrieval instead of gracefully validating names.

Reproduction

from api.tools.utils import is_valid_plugin
is_valid_plugin("git")

Observed: FileNotFoundError for plugin_names.json.

Proposed fix

Resolve from the module directory first, then normalize:

tools_dir = os.path.dirname(os.path.abspath(__file__))
list_plugin_names_path = os.path.normpath(
    os.path.join(tools_dir, "..", "..", "data", "raw", "plugin_names.json")
)

Acceptance criteria

  • is_valid_plugin("git") returns True (or at least does not raise file-path errors)
  • unknown plugin names return False
  • regression unit test added for this path-resolution behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions