Status: Resolved (View Workflow)
Under some conditions adding a dynamic section to a configuration screen fails with the abovementioned error. In renderOnDemand, c.innerHTML = "<TABLE><TBODY>"+t.responseText+"</TBODY></TABLE>"; succeeds yet immediately afterwards c.firstChild is a HTMLLinkElement rather than the expected HTMLTableElement:
<link rel="stylesheet" href="/adjuncts/…/lib/form/section_.css" type="text/css">
The second child is indeed the expected table, so something inserted this link element at the top.
Uri Scheiner says this occurred for him due to <f:advanced> under a separated <f:section>, yet it seems to occur under other circumstances as well.
Seems to be a bug in Chrome; cannot reproduce in Firefox. The stylesheet link was generated by Stapler in the original HTML as part of another table; there is no reason for it to be duplicated when innerHTML is set.
Bumping up priority since it can break forms with no apparent workaround other than using a different browser. Still have not pinpointed the conditions under which it occurs; a given plugin can have two describables in a pulldown, and selecting the first triggers this bug, while selecting the second does not.
Code changed in jenkins
User: Jesse Glick
[FIXED JENKINS-15494] Uncaught TypeError: Cannot read property 'firstChild' of null
Wrapping an <f:section> in <f:nested><table style="width:100%">…</table></f:nested> seems to work around the bug.
Integrated in jenkins_main_trunk #2000
[FIXED JENKINS-15494] Uncaught TypeError: Cannot read property 'firstChild' of null (Revision 8dbee911c39343c3085a4f56f6e597719ba0c0ca)
Result = SUCCESS
Jesse Glick : 8dbee911c39343c3085a4f56f6e597719ba0c0ca
Another test case to reproduce: CloudBees Templates plugin, create builder template using hetero components from dtor (one each) of type hudson.tasks.Publisher, try to add this builder to a job. Reproducible from 1.455 (unsurprising since https://github.com/jenkinsci/jenkins/compare/jenkins-1.454...jenkins-1.455 shows extensive JS changes); fixed in 1.487 with this patch.
Apparently a regression between 1.447 and 1.466.