Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-63355] Prevent NPEs when library name is not provided #101

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Dohbedoh
Copy link

@Dohbedoh Dohbedoh commented Dec 18, 2023

JENKINS-63355 Prevent NPEs in cases where the library name is not provided (if a library without name is accessible - in the context of a pipeline - then the library step would fail with a NPE, regardless of the library it tries to find)

Testing done

  • Start a controller
  • Add a Global Pipeline Library pointing to a repo with a hello world step.
  • Create a Folder, use defaults
  • Create a hello world pipeline that uses the above library via the library step. e.g. library "test-steps"; helloWorld()
  • Run the pipeline to confirm that it succeeds
  • Configure Folder
    • Find "Pipeline Libraries" section and click "Add"
    • Ignore the error about the library name and click "Save"
  • Run the pipeline again
  • Make sure that the pipeline succeeds

Submitter checklist

Preview Give feedback

@Dohbedoh Dohbedoh requested a review from a team as a code owner December 18, 2023 13:04
@jglick jglick added the bug Something isn't working label Dec 18, 2023
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

So what happens if a library with a null name was saved before this change? @LocalData

@@ -184,7 +191,7 @@ public FormValidation doCheckDefaultVersion(@AncestorInPath Item context, @Query
} else {
for (LibraryResolver resolver : ExtensionList.lookup(LibraryResolver.class)) {
for (LibraryConfiguration config : resolver.fromConfiguration(Stapler.getCurrentRequest())) {
if (config.getName().equals(name)) {
if (name.equals(config.getName())) {
Copy link
Member

Choose a reason for hiding this comment

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

could be reverted

@@ -177,7 +180,7 @@ public static class Execution extends AbstractSynchronousNonBlockingStepExecutio
if (retriever == null) {
for (LibraryResolver resolver : ExtensionList.lookup(LibraryResolver.class)) {
for (LibraryConfiguration cfg : resolver.forJob(run.getParent(), Collections.singletonMap(name, version))) {
if (cfg.getName().equals(name)) {
if (name.equals(cfg.getName())) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@Dohbedoh
Copy link
Author

So what happens if a library with a null name was saved before this change?

Actually still fails. Need to rework this. We need to skip those libraries. But probably also tell the user about it.

@jglick jglick marked this pull request as draft May 14, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants