Skip to content

Conversation

@mawinter69
Copy link
Contributor

@mawinter69 mawinter69 commented Nov 3, 2025

The current implementation based on an enum is not very flexible, It basically avoids that one can write an implementation of another provider in a separate plugin. And one has to change a lot of places to create a new provider.
This change makes the provider an ExtensionPoint. This has some advantages like provider specific requirements checking. E.g. the apiKey is mandatory for OpenAI and Gemini but not required for Ollama. And for Ollama a url is mandatory.
The code is also a lot simpler and avoids special checks. Providers implement checks if the config is valid avoiding unnecessary calls to the provider when we know the request will fail anyway, e.g. due to a missing apikey or a missing model.
This would also make it easily possible to change the plugin to have multiple providers configured, either from different providers or different models from the same provider.

Existing configuration is automatically converted to the new format.

When disabling the plugin the configuration of the provider is not lost.

Also fixes #31

Open points:

  • connection validation
  • update readme/images
  • CasC: The old setters and getters are still there. This allows CasC to accept the old yaml and the new yaml.
  • Add tests that old config still works both xml format and CasC yaml

Before:
image

After:
No dropdown when disabled:
image

Dropdown with specific config when enabled
Ollama:
image

OpenAI:
image

Testing done

Adjusted the tests accordingly.
Added tests that ensure the old config formats for the xml and casc are loaded properly

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

The current implementation based on an enum is not very flexible, It
basically avoids that one can write an implementation of another
provider in a separate plugin. And one has to change a lot of places to
create a new provider.
This change makes the provider an ExtensionPoint. This has some
advantages like provider specific requirements checking. E.g. the apiKey
is mandatory for OPOenAI and Gemini but not required for Ollama. And for
Ollama a url is mandatory.
The code is also a lot simpler and avoids special checks. Providers
implement checks if the config is valid avoiding unnecessary calls to
the provider when we know the request will fail anyway, e.g. due to
a missing apikey or a missing model.
This would also make it easily possible to change the plugin to have
multiple providers configured, either from different providers or
different modeld from the same provider.

</dependencies>

<build>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to disable the enforcer rules with configuring corresponding exclusions

include the provider name when displaying existing explanations
add a tooltip to the Explain error button in the appbar of the console
view
@mawinter69 mawinter69 mentioned this pull request Nov 3, 2025
@shenxianpeng shenxianpeng added the major-rfe For changelog: Major enhancement. Will be highlighted on the top label Nov 4, 2025
@shenxianpeng
Copy link
Member

Thank you so much for these awesome changes! Can’t wait to see users benefit from them soon.

@mawinter69 mawinter69 marked this pull request as ready for review November 5, 2025 17:54
@mawinter69 mawinter69 requested a review from a team as a code owner November 5, 2025 17:54
}

@Test
void testExistingExplanationDetection() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the removed tests didn't test anything from the ConsoleExplainErrorAction class. What they tested is already covered in ErrorExplanationActionTest

@shenxianpeng
Copy link
Member

shenxianpeng commented Nov 5, 2025

For sidebar name — it would be even better if it didn’t change based on the provider name.

image

After entering the API key for OpenAI, the “Field is required” message still appears. (It works fine for Gemini.)

image

@mawinter69
Copy link
Contributor Author

For sidebar name — it would be even better if it didn’t change based on the provider name.

Fixed that.
With the latest change I've also changed a lot in the way how errors are handled. There was quite some code duplicated in the methods and error handling was not really existent but just returned string that said there was an error. The explainError from the BaseAIProvider now throws Exception and those are handled to forward that information to the corresponding places.

After entering the API key for OpenAI, the “Field is required” message still appears. (It works fine for Gemini.)

I'm not able to reproduce that. Note that the check is only executed after the field loses focus

@panicking
Copy link
Contributor

@MarkEWaite I Will test over the weekend

@shenxianpeng
Copy link
Member

shenxianpeng commented Nov 8, 2025

I’ve tested the latest changes and everything looks good. If there are no further updates or comments, I plan to merge this on Monday or Tuesday next week. Thanks a lot!

@shenxianpeng shenxianpeng merged commit 83726db into jenkinsci:main Nov 10, 2025
17 checks passed
shenxianpeng added a commit that referenced this pull request Nov 10, 2025
closes #55 fixup of #51

### Testing done

<!-- Comment:
Provide a clear description of how this change was tested.
At minimum this should include proof that a computer has executed the
changed lines.
Ideally this should include an automated test or an explanation as to
why this change has no tests.
Note that automated test coverage is less than complete, so a successful
PR build does not necessarily imply that a computer has executed the
changed lines.
If automated test coverage does not exist for the lines you are
changing, you must describe the scenario(s) in which you manually tested
the change.
For frontend changes, include screenshots of the relevant page(s) before
and after the change.
For refactoring and code cleanup changes, exercise the code before and
after the change and verify the behavior remains the same.
-->

### Submitter checklist
- [x] Make sure you are opening from a **topic/feature/bugfix branch**
(right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired
changelog entry
- [x] Please describe what you did
- [x] Link to relevant issues in GitHub or Jira
- [ ] Link to relevant pull requests, esp. upstream and downstream
changes
- [ ] Ensure you have provided tests that demonstrate the feature works
or the issue is fixed

<!--
Put an `x` into the [ ] to show you have filled the information.
The template comes from
https://github.com/jenkinsci/.github/blob/master/.github/pull_request_template.md
You can override it by creating .github/pull_request_template.md in your
own repository
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major-rfe For changelog: Major enhancement. Will be highlighted on the top

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include provider info to the title of AI Error Explanation

3 participants