Add enableValidation option as partial workaround for paginated REST APIs#260
Open
Arbuzov wants to merge 1 commit into
Open
Add enableValidation option as partial workaround for paginated REST APIs#260Arbuzov wants to merge 1 commit into
Arbuzov wants to merge 1 commit into
Conversation
…APIs Adds an advanced "Enable Value Validation" checkbox (default true) to the RestListParameterDefinition. When unchecked, the build form renders a free-text input backed by a datalist of the fetched values instead of the strict select2 dropdown, and isValid() short-circuits true for any non-null submitted value. This lets users pick a known value or type one that the REST endpoint did not surface in its first page — a partial workaround for paginated APIs that return only a slice of the available options. The option is exposed as a DataBoundSetter so the Pipeline DSL accepts it (RESTList(..., enableValidation: false)), and four new tests cover the default, the bypass on isValid, the createValue path, and the DescribableModel pipeline binding. This only addresses the symptom. The plugin still does not follow link-headers or continuation tokens, so the underlying gaps tracked in jenkinsci#61 (paged JSON / link-header pagination) and jenkinsci#86 (continuation tokens) remain open. The pom.xml change is a separate concern but lands in the same commit because without it every job's RestListParameterDefinition silently disappears after a clean rebuild on maven-compiler-plugin 3.14: target/classes/META-INF/annotations/ is emptied during the test phases even with <proc>none</proc> + <useIncrementalCompilation>false</useIncrementalCompilation> on default-testCompile, so the packaged hpi ships without the @extension annotation-indexer index. With the index missing, ExtensionList.lookupSingleton fails inside RestListParameterDefinition.<clinit> and XStream's RobustReflectionConverter swallows the resulting ExceptionInInitializerError while loading job configs, silently dropping the parameter. An antrun stash/restore around the test phases keeps the index in the jar. Tested on a Jenkins 2.541.3 sandbox as both a freestyle project and a declarative pipeline, including a caller pipeline invoking a downstream RLP pipeline with a free-text value via build job parameters. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Semantic question about
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
true) toRestListParameterDefinition. Unchecked → the build form renders a free-text<input>backed by a<datalist>of the fetched values instead of the strictselect2dropdown, andisValid()short-circuitstruefor any non-null submitted value.@DataBoundSetter, so the Pipeline DSL also acceptsRESTList(..., enableValidation: false).isValid()bypass, thecreateValue()path, and theDescribableModelpipeline binding.This is a deliberately small workaround for a real footgun: when the REST endpoint returns a paginated response and the value the user wants is not on the first page, today they have no way to launch the build. They asked for a way to "just type it in." With validation off, they can.
Motivation — partial fix for pagination gaps
This does not make the plugin follow
Linkheaders or continuation tokens. It is the cheapest possible escape hatch so that paginated endpoints remain usable until proper pagination support lands:Both issues remain open; I think this PR is worth landing on its own, and a follow-up can wire up actual pagination handling.
Build fix bundled in (separate concern)
The
pom.xmlchange is unrelated to the feature itself but lives in the same commit because without it the feature would silently appear to do nothing on some environments. Under maven-compiler-plugin 3.14,target/classes/META-INF/annotations/is wiped during the test phases even with the existing<compilerArgument>-proc:none</compilerArgument>override. The packaged hpi then ships without thehudson.Extensionannotation-indexer index,ExtensionList.lookupSingleton(RestListParameterGlobalConfig.class)fails inside the static initializer ofRestListParameterDefinition, and XStream'sRobustReflectionConverterswallows the resultingExceptionInInitializerErrorwhile deserializing job configs — silently dropping everyRestListParameterDefinitionfrom every job. The user sees no errors anywhere, just empty parameters at build time and "Invalid parameter type RESTList" from the Pipeline DSL.The fix:
<compilerArgument>-proc:none</compilerArgument>with the native<proc>none</proc>plus<useIncrementalCompilation>false</useIncrementalCompilation>ondefault-testCompile.antrunstash/restore around the test phases (process-classes→prepare-package) so the index lands in the jar even if any future plugin in the lifecycle empties the directory again.Happy to split this into a separate PR if maintainers prefer.
Test plan
enableValidationDefaultsToTrue,isValidAcceptsArbitraryValueWhenValidationDisabled,createValueAcceptsArbitraryWhenValidationDisabled,pipelineDslAcceptsEnableValidationFalse.enableValidation=true: bogus value viabuildWithParameters?TAG=fooreturns HTTP 500 (rejected); valid github tag returns 201 and the build runs with the value.enableValidation=false: free-text value is accepted, build logs showTAG=freely-typed-page2-value.pipeline { parameters { RESTList(..., enableValidation: false) } }): identical behaviour.build job: 'downstream', parameters: [string(name: 'TAG', value: 'crosspipe-page2-value')]— Jenkins converts the string to aRestListParameterValue, validation short-circuits because the downstream hasenableValidation=false, and the downstream build runs with the value..hpicontainsMETA-INF/annotations/hudson.Extensionso the singleton lookup succeeds and XStream loads the parameter.🤖 Generated with Claude Code