Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
This is a fix for an unreleased regression. As of #8278,
hudson.tasks.junit.JUnitResultArchiverTest#setDescription
started failing in PCT with:Evaluation
After debugging this, I can see that #8278 exposed a pre-existing bug by making the browser's behavior more strict.
The original bug was actually introduced in #6511. Here we have a Jelly editable description in the JUnit plugin that sets a permission attribute (required), a description attribute (optional), but no submission URL (also optional). This seems like a completely valid thing to do, but the code in
editable-description.js
from #6511 only handles two cases:Here the description is set, but the submission URL is not set, and the code in
editable-description.js
from #6511 does not handle this third case. It invokesreplaceDescription
with a non-null description (the one from the JUnit plugin'sgetDescription()
method) and a null submission URL. ThereplaceDescription
function, similarly assuming that either both are set or neither are set, sees that the submission URL is not undefined (that's right, it's defined as null) and passes this into theparameters
object.So far the code is buggy, but this was never a problem in practice in the Prototype implementation of
replaceDescription
(because Prototype converted null values into the empty string) or before #8278, but it is a problem after #8278. If I had to guess why #8278 made any difference, it would be that adding the header possibly puts the browser in a more strict mode. In any case the root cause of this whole problem is not #8278 but rather that #6511 failed to handle this legitimate case.Solution
To fix this I read the documentation noting that
so I fixed the (sole) caller of
replaceDescription
to always call it with the result ofElement#getAttribute
(either a valid string or null) and then set the description and parameters separately in the form object inreplaceDescription
based on whether or not those passed-in values were null and non-empty. There is no need to check forundefined
anymore since that is never returned byElement#getAttribute
.Testing done
hudson.tasks.junit.JUnitResultArchiverTest#setDescription
failed after #8278 (not yet released) but without this PR and now passes with this PR.Proposed changelog entries
N/A
Proposed upgrade guidelines
N/A
Submitter checklist
Desired reviewers
@mention
Before the changes are marked as
ready-for-merge
:Maintainer checklist