Details
-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
None
-
2
-
Severity 3 - Minor
-
0
-
Description
Issue Summary
Git repository type doesn't sanitize Git command timeout values which can cause the Bamboo Administration >> Repository Settings panel not to render any repositories.
Steps to Reproduce
- Add a Git repository type and clear the Command timeout value to an empty string
- Visit Bamboo Administration >> Repository Settings
Expected Results
Validate the input.
Actual Results
Input is not validated and accepts strings. Repository settings screen no longer renders repositories.
The below exception is thrown in the atlassian-bamboo.log file:
2019-04-16 15:29:16,348 INFO [http-nio-8085-exec-8] [AccessLogFilter] user GET http://bamboo:8085/admin/repositorySettings.action 305349kb 2019-04-16 15:29:16,391 ERROR [http-nio-8085-exec-8] [runtime] Error executing FreeMarker template FreeMarker template error: An error has occurred when reading existing sub-variable "cacheDescriptions"; see cause exception! The type of the containing value was: extended_hash+string (com.atlassian.bamboo.plugins.git.GitRepository wrapped into f.e.b.StringModel) ---- FTL stack trace ("~" means nesting-related): - Failed at: #list cacheProvider.cacheDescriptions... [in template "admin/repositorySettings.ftl" in macro "manageCachesTab" at line 78, column 17] - Reached through: @ww.form action="repositorySettingsDe... [in template "admin/repositorySettings.ftl" in macro "manageCachesTab" at line 39, column 9] - Reached through: @manageCachesTab [in template "admin/repositorySettings.ftl" at line 19, column 9] ~ Reached through: #nested [in template "lib/dojo.ftl" in macro "contentPane" at line 98, column 5] ~ Reached through: @dj.contentPane labelKey="manageCache... [in template "admin/repositorySettings.ftl" at line 18, column 5] ~ Reached through: #nested [in template "lib/dojo.ftl" in macro "tabContainer" at line 66, column 5] ~ Reached through: @dj.tabContainer headingKeys=["manage... [in template "admin/repositorySettings.ftl" at line 17, column 1] ---- Java stack trace (for programmers): ---- freemarker.core._TemplateModelException: [... Exception message was already printed; see it above ...] at freemarker.ext.beans.BeanModel.get(BeanModel.java:187) at freemarker.core.Dot._eval(Dot.java:43) ... at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1459) at freemarker.ext.beans.BeanModel.invokeThroughDescriptor(BeanModel.java:236) at freemarker.ext.beans.BeanModel.get(BeanModel.java:154) ... 313 more Caused by: io.atlassian.util.concurrent.LazyReference$InitializationException: org.apache.commons.configuration.ConversionException: 'repository.git.commandTimeout' doesn't map to an Integer object at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:156) at io.atlassian.util.concurrent.LazyReference.get(LazyReference.java:116) at com.atlassian.bamboo.repository.LegacyRepositoryDataImpl.getRepository(LegacyRepositoryDataImpl.java:134) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) at com.atlassian.bamboo.plugins.git.GitRepositoryFacade.lambda$static$0(GitRepositoryFacade.java:31) at com.atlassian.bamboo.plugins.git.GitCacheHandler.lambda$getCacheDescriptions$0(GitCacheHandler.java:98) at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:174) at sun.reflect.GeneratedMethodAccessor2316.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26) at com.sun.proxy.$Proxy463.withVariableSubstitutor(Unknown Source) at sun.reflect.GeneratedMethodAccessor2316.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) ... at com.sun.proxy.$Proxy947.withVariableSubstitutor(Unknown Source) at com.atlassian.bamboo.plugins.git.GitCacheHandler.getCacheDescriptions(GitCacheHandler.java:97) at com.atlassian.bamboo.plugins.git.GitRepository.getCacheDescriptions(GitRepository.java:1187) ... 320 more Caused by: org.apache.commons.configuration.ConversionException: 'repository.git.commandTimeout' doesn't map to an Integer object at org.apache.commons.configuration.AbstractConfiguration.getInteger(AbstractConfiguration.java:880) at org.apache.commons.configuration.AbstractConfiguration.getInt(AbstractConfiguration.java:851) at com.atlassian.bamboo.plugins.git.GitRepository.populateFromConfig(GitRepository.java:704) at com.atlassian.bamboo.repository.RepositoryReference.create(RepositoryReference.java:28) at com.atlassian.bamboo.repository.RepositoryReference.create(RepositoryReference.java:12) at io.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:332) at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:150) ... 361 more Caused by: org.apache.commons.configuration.ConversionException: Could not convert to java.lang.Integer at org.apache.commons.configuration.PropertyConverter.toNumber(PropertyConverter.java:312) at org.apache.commons.configuration.PropertyConverter.toInteger(PropertyConverter.java:157) at org.apache.commons.configuration.AbstractConfiguration.getInteger(AbstractConfiguration.java:876) ... 367 more Caused by: java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:592) at java.lang.Integer.<init>(Integer.java:867) at sun.reflect.GeneratedConstructorAccessor389.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.commons.configuration.PropertyConverter.toNumber(PropertyConverter.java:308) ... 369 more
Notes
Bitbucket Server repository type sanitizes the input and it cannot be reproduced with this repository type.
Workaround
Find the affected repositories by running the below SQL on your Bamboo database:
SELECT B.FULL_KEY As PlanKey, VCS.*
FROM VCS_LOCATION VCS
LEFT OUTER JOIN PLAN_VCS_LOCATION PV ON VCS.VCS_LOCATION_ID=PV.VCS_LOCATION_ID
LEFT OUTER JOIN BUILD B ON PV.PLAN_ID = B.BUILD_ID
WHERE XML_DEFINITION_DATA LIKE '%repository.git.commandTimeout</string><string></string>%';
- Note the above SQL finds an empty string value. It's possible that this error can be caused by any non-integer value and not just empty strings. You should use the string reported in the NumberFormatException and substitute it inside the LIKE clause of the SQL statement, between <string></string>. E.g. <string>stringhere</string>
Edit the repositories identified in the SQL and change >> Advanced options >> Command timeout value to be an integer value >> Save.