It is a common trick to use StaplerRequest.getAncestor to find the model object being configured in a form so that Java code run on the back end can have some context. This works fine if the configuration block was part of the main page load. But if it was injected in a lazy block, e.g. by adding a repeatable section, the request URI is /$stapler/bound/.../render and there are no ancestors, so getAncestor quietly returns null!
This is especially insidious because you may iteratively test a feature relying on getAncestor successfully, by reloading .../configure after making code changes; but if you never try adding the section for the first time you might never notice this problem.
The workaround is to check for a Referer header and manually parse this out to find the model object of interest. But Stapler ought to do this for you automatically.
- is blocking
-
JENKINS-20959 f:descriptorRadioList does not render contents lazily
- Open
-
JENKINS-68338 Credentials popup does not work (regression in 2.344)
- Closed
-
JENKINS-26093 Code snippet generation for BuildTriggerStep.parameters
- Resolved
- is related to
-
JENKINS-24165 Inappropriate Ancestor list from a @JavaScriptMethod
- Open
-
JENKINS-36315 Confusion on how to get form validation URLs in config.jelly
- Closed
- relates to
-
JENKINS-35243 ItemGroup.getUrlChildPrefix not honored by views
- Open
- links to