Skip to content

fix: correct plugin catalog path resolution in is_valid_plugin (fixes #245)#246

Open
Flamki wants to merge 3 commits intojenkinsci:mainfrom
Flamki:fix/is-valid-plugin-path
Open

fix: correct plugin catalog path resolution in is_valid_plugin (fixes #245)#246
Flamki wants to merge 3 commits intojenkinsci:mainfrom
Flamki:fix/is-valid-plugin-path

Conversation

@Flamki
Copy link
Contributor

@Flamki Flamki commented Mar 5, 2026

Fixes #245.

Description

is_valid_plugin() was resolving plugin_names.json using os.path.abspath(__file__) as if it were a directory, which can produce an invalid path and raise FileNotFoundError.

This PR fixes path resolution and adds a regression unit test.

Changes

  • chatbot-core/api/tools/utils.py
    • resolve path from module directory:
      • tools_dir = os.path.dirname(os.path.abspath(__file__))
      • os.path.normpath(os.path.join(tools_dir, "..", "..", "data", "raw", "plugin_names.json"))
  • chatbot-core/tests/unit/tools/test_utils.py
    • test_is_valid_plugin_returns_true_for_known_plugin
    • test_is_valid_plugin_returns_false_for_unknown_plugin

Why this is aligned / scoped

  • Small backend reliability fix (no architecture change)
  • Directly improves plugin retrieval stability
  • No overlap with auth/design-phase Java/Gatekeeper work

Testing done

  • pytest tests/unit/tools/test_utils.py -q -> 2 passed
  • pylint api/tools/utils.py tests/unit/tools/test_utils.py -> 10.00/10

Submitter checklist

  • Topic branch used
  • PR title reflects intended changelog
  • Changes described
  • Linked issue
  • Added tests for the fix

@Flamki Flamki requested a review from a team as a code owner March 5, 2026 09:43
@berviantoleo berviantoleo added the bug For changelog: Minor bug. Will be listed after features label Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug For changelog: Minor bug. Will be listed after features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants