tomasbjerre / pull-request-notifier-for-bitbucket

Bitbucket Server plugin that invokes a custom URL when a pull request event is triggered.
Other
185 stars 74 forks source link

Variable renderer tries to render extra variables #233

Closed rezen closed 7 years ago

rezen commented 7 years ago

It seems there is an issue with the variable renderer that causes it to attempt to render non-existant variables, such as $host in this case which was part of the commit title.

Steps to reproduce

Pull Request Notifier 3.2 Atlassian Bitbucket v5.1.4

2017-07-17 07:52:56,619 ERROR [http-nio-8080-exec-4] ahermosilla @1TE68TRx472x1160432x1 15brlxb 10.15.130.204,0:0:0:0:0:0:0:1 "POST /rest/prnfb-admin/1.0/settings/buttons/c0c2dc7d-bcaa-4f46-a488-c80f37c64f16/press/repository/308/pullrequest/233 HTTP/1.1" c.a.p.r.c.e.j.ThrowableExceptionMapper Uncaught exception thrown by REST service: Tried to replace \$\{PULL_REQUEST_TITLE\} with BNRSD-387 Fix circular reference logging on $host errors in RSD abstract client
java.lang.RuntimeException: Tried to replace \$\{PULL_REQUEST_TITLE\} with BNRSD-387 Fix circular reference logging on $host errors in RSD abstract client
        at se.bjurr.prnfb.service.PrnfbRenderer.getRenderedStringResolved(PrnfbRenderer.java:96)
        at se.bjurr.prnfb.service.PrnfbRenderer.renderVariable(PrnfbRenderer.java:150)
        at se.bjurr.prnfb.service.PrnfbRenderer.render(PrnfbRenderer.java:117)
        at se.bjurr.prnfb.listener.PrnfbPullRequestEventListener.notify(PrnfbPullRequestEventListener.java:242)
        at se.bjurr.prnfb.service.ButtonsService.doHandlePressed(ButtonsService.java:108)
        at se.bjurr.prnfb.service.ButtonsService.handlePressed(ButtonsService.java:160)
        at se.bjurr.prnfb.presentation.ButtonServlet.press(ButtonServlet.java:172)
        at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
        at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
        at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
        at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
        at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24)
        at com.atlassian.analytics.client.filter.UniversalAnalyticsFilter.doFilter(UniversalAnalyticsFilter.java:92)
        at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:39)
        at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
        at com.atlassian.plugin.connect.plugin.auth.scope.ApiScopingFilter.doFilter(ApiScopingFilter.java:81)
        at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
        at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:88)
        at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:112)
        at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75)
        at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94)
        at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67)
        at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
        at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:109)
        at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32)
        at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:38)
        at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:39)
        at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42)
        at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:90)
        at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73)
        at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:89)
        at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.lang.Thread.run(Thread.java:745)
        ... 237 frames trimmed
Caused by: java.lang.IllegalArgumentException: Illegal group reference
        at java.util.regex.Matcher.appendReplacement(Matcher.java:857)
        at java.util.regex.Matcher.replaceAll(Matcher.java:955)
        at java.lang.String.replaceAll(String.java:2211)
        at se.bjurr.prnfb.service.PrnfbRenderer.getRenderedStringResolved(PrnfbRenderer.java:94)
        ... 34 common frames omitted
/rest/prnfb-admin/1.0/settings
{"adminRestriction":"ADMIN","keyStoreType":"","shouldAcceptAnyCertificate":false}
/rest/prnfb-admin/1.0/settings/buttons
[{"buttonFormList":[],"buttonFormListString":"[]","name":"","projectKey":"BNCON","repositorySlug":"console","userLevel":"EVERYONE","uuid":"41b2eb35-8cd3-4cc4-bb58-ffb4a9c51f9e"},{"buttonFormList":[],"buttonFormListString":"[]","confirmation":"off","name":"CodeClimate","userLevel":"SYSTEM_ADMIN","uuid":"9ee34a06-7246-48b9-a3e9-79578b6ef4b9","confirmationText":"confirmationText"},{"buttonFormList":[],"buttonFormListString":"[]","name":"Jenkins Build","projectKey":"PHPLIBS","userLevel":"EVERYONE","uuid":"3679e03e-70bf-4b9e-a72d-3057829d4358"},{"buttonFormList":[],"buttonFormListString":"[]","name":"Trigger Jenkins","projectKey":"BNCON","repositorySlug":"console","uuid":"5dca83a4-bf43-4b9e-bbd5-ce18638563a2"},{"buttonFormList":[],"buttonFormListString":"[]","name":"Trigger Jenkins","projectKey":"BNCS","repositorySlug":"bcs","userLevel":"EVERYONE","uuid":"5acd9d75-6364-49b4-bed0-8e864c4e389e"},{"buttonFormList":[],"buttonFormListString":"[]","name":"Trigger Jenkins Build","projectKey":"BNRSD","repositorySlug":"rsd","userLevel":"EVERYONE","uuid":"c0c2dc7d-bcaa-4f46-a488-c80f37c64f16"}]
/rest/prnfb-admin/1.0/settings/notifications
[{"filterRegexp":"^(BNAUTH|BNCPY|BNBS|BNRSD|PHPLIBS)$","filterString":"${PULL_REQUEST_FROM_REPO_PROJECT_KEY}","headers":[{"name":"X-Atlassian-Token","value":"no-check"},{"name":"X-Stash-Event","value":"pull_request"}],"method":"POST","name":"Code Climate","postContent":"payload[id]=${PULL_REQUEST_ID}&payload[action]=${PULL_REQUEST_ACTION}&payload[url]=${PULL_REQUEST_URL}&payload[version]=${PULL_REQUEST_VERSION}&payload[author_display_name]=${PULL_REQUEST_AUTHOR_DISPLAY_NAME}&payload[author_email]=${PULL_REQUEST_AUTHOR_EMAIL}&payload[author_id]=${PULL_REQUEST_AUTHOR_ID}&payload[author_name]=${PULL_REQUEST_AUTHOR_NAME}&payload[author_slug]=${PULL_REQUEST_AUTHOR_SLUG}&payload[from_ssh_clone_url]=${PULL_REQUEST_FROM_SSH_CLONE_URL}&payload[from_http_clone_url]=${PULL_REQUEST_FROM_HTTP_CLONE_URL}&payload[from_id]=${PULL_REQUEST_FROM_ID}&payload[from_branch]=${PULL_REQUEST_FROM_BRANCH}&payload[from_repo_id]=${PULL_REQUEST_FROM_REPO_ID}&payload[from_repo_name]=${PULL_REQUEST_FROM_REPO_NAME}&payload[from_repo_project_id]=${PULL_REQUEST_FROM_REPO_PROJECT_ID}&payload[from_repo_project_key]=${PULL_REQUEST_FROM_REPO_PROJECT_KEY}&payload[from_repo_slug]=${PULL_REQUEST_FROM_REPO_SLUG}&payload[to_ssh_clone_url]=${PULL_REQUEST_TO_SSH_CLONE_URL}&payload[to_http_clone_url]=${PULL_REQUEST_TO_HTTP_CLONE_URL}&payload[to_hash]=${PULL_REQUEST_TO_HASH}&payload[to_id]=${PULL_REQUEST_TO_ID}&payload[to_branch]=${PULL_REQUEST_TO_BRANCH}&payload[to_repo_id]=${PULL_REQUEST_TO_REPO_ID}&payload[to_repo_name]=${PULL_REQUEST_TO_REPO_NAME}&payload[to_repo_project_id]=${PULL_REQUEST_TO_REPO_PROJECT_ID}&payload[to_repo_project_key]=${PULL_REQUEST_TO_REPO_PROJECT_KEY}&payload[to_repo_slug]=${PULL_REQUEST_TO_REPO_SLUG}&payload[pull_request_title]=${PULL_REQUEST_TITLE}&payload[from_hash]=${PULL_REQUEST_FROM_HASH}","proxyPort":-1,"triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["APPROVED","COMMENTED","DECLINED","MERGED","OPENED","BUTTON_TRIGGER","REOPENED","RESCOPED_FROM","RESCOPED_TO","UNAPPROVED","UPDATED"],"url":"https://redacted.com/webhooks","uuid":"b4357dd8-1c3f-451b-9ca5-951ad7a8f474","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"NG-Web-Codequality","projectKey":"BFW","repositorySlug":"ngwebui","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED","MERGED"],"triggers":["OPENED","BUTTON_TRIGGER","REOPENED","UPDATED"],"url":"http://x.x.x.1:8080/jenkins/view/NGWebui%20tests%20builds/job/NGWeb%20Codequality/build?token=codequality","uuid":"92f828b5-2089-4a3c-8cd1-c555cd77a5cb","postContentEncoding":"NONE"},{"headers":[],"method":"GET","name":"ng-web-branch-build","password":"420sushi","projectKey":"BFW","repositorySlug":"ngwebui","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED","MERGED"],"triggers":["OPENED","BUTTON_TRIGGER","REOPENED","UPDATED"],"url":"http://x.x.x.1:8080/jenkins/job/ng%20branch%20builds/buildWithParameters?token=build","user":"root","uuid":"343b7856-2737-4972-950a-395ee43ea7d1","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"ng-web-release-build","password":"420sushi","projectKey":"BFW","repositorySlug":"ngwebui","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED"],"triggers":["MERGED"],"url":"http://x.x.x.1:8080/jenkins/job/ng%20release%20builds/buildWithParameters?token=build","user":"root","uuid":"e337ae2f-342c-481f-9356-ec0f19d0ba11","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"sync-scripts","projectKey":"BFW","repositorySlug":"bfwbuild","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED","MERGED"],"triggers":["APPROVED","MERGED","BUTTON_TRIGGER","UPDATED"],"url":"http://x.x.x.1:8080/jenkins/job/sync%20bfwbuild%20repo/buildWithParameters?token=updatescripts","uuid":"dddb9ea5-521a-4c60-b1cb-d3d48d53b776","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"testing-code-quality","password":"420sushi","projectKey":"BFW","repositorySlug":"webui","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED","MERGED"],"triggers":["OPENED","BUTTON_TRIGGER","REOPENED","UPDATED"],"url":"http://x.x.x.1:8080/jenkins/view/testing%20-%20code%20quality/job/Web%20Codequality%20Check%20git//build?token=codequality","user":"root","uuid":"3ec47d6d-67f9-445d-bf74-d422b8bc2a48","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-branch-build","password":"420sushi","projectKey":"BFW","repositorySlug":"webui","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED","MERGED"],"triggers":["OPENED","BUTTON_TRIGGER","REOPENED","UPDATED"],"url":"http://x.x.x.1:8080/jenkins/job/branch%20builds/buildWithParameters?token=build&BUILD_ON=buildslave3","user":"root","uuid":"dc11640d-a024-491b-aa6f-01596c141b8d","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/job/pre_merge_build/build${EVERYTHING_URL}","uuid":"368838e0-7517-4701-96c5-8519c4132191","postContentEncoding":"NONE"},{"headers":[],"method":"GET","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/job/pre_merge_build/build${EVERYTHING_URL}","uuid":"87f57ced-6d58-4199-b421-7b7f954d7518","postContentEncoding":"NONE"},{"headers":[],"method":"GET","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/git/notifyCommit?${EVERYTHING_URL}","uuid":"defd154f-1acb-4485-83a2-43e7358dd622","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/job/pre_merge_build/buildWithParamaters?${EVERYTHING_URL}","uuid":"4a6ff126-e570-44b9-aaa7-443312e209a3","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/git/notifyCommit?url=${PULL_REQUEST_URL}","uuid":"9f6ba786-a961-4468-824e-3a023cfa3bd7","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/job/pre_merge_build/buildWithParamaters?token=6KkpWdjcWzRmuktwnGBR&${EVERYTHING_URL}","uuid":"e3a581ff-3414-47f3-a091-c952ede8f1aa","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/job/pre_merge_build/buildWithParameters?token=6KkpWdjcWzRmuktwnGBR&${EVERYTHING_URL}","uuid":"3d51d64a-2c4f-4966-a4d7-0710018d346b","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNCON","repositorySlug":"console","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["BUTTON_TRIGGER"],"url":"http://x.x.x.2:8080/git/notifyCommit?url=${PULL_REQUEST_FROM_SSH_CLONE_URL}","uuid":"866b592d-b71a-4a14-89ea-117da42695de","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNESS","repositorySlug":"sideband-mailer","triggerIfCanMerge":"ALWAYS","triggerIgnoreStateList":[],"triggers":["MERGED"],"url":"https://redacted.com/view/SIDEBAND_MAILER/job/SIDEBAND_MAILER/buildWithParameters?token=rtD[8HR-;5Z:sTeg\\F.7gG'e76!KQ&cause=${PULL_REQUEST_TITLE}","uuid":"3425d782-cc69-4e47-b9a9-d0cf42c5dce9","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-build","projectKey":"BNRSD","repositorySlug":"rsd","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED","MERGED"],"triggers":["OPENED","BUTTON_TRIGGER","REOPENED"],"url":"https://redacted.com/git/notifyCommit?url=${PULL_REQUEST_FROM_SSH_CLONE_URL}","uuid":"d577dd64-abf7-4254-991e-79c7c22d4b46","postContentEncoding":"NONE"},{"headers":[],"method":"POST","name":"trigger-jenkins-build","projectKey":"PHPLIBS","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED","MERGED"],"triggers":["OPENED","BUTTON_TRIGGER","RESCOPED_FROM"],"url":"http://jenkins2.bbs.arb.cudaops.com/git/notifyCommit?url=${PULL_REQUEST_FROM_SSH_CLONE_URL}","uuid":"dbbf945e-0d3c-4165-90bd-df80e31e2225","postContentEncoding":"NONE"},{"headers":[],"method":"GET","name":"trigger-release-build","password":"420sushi","projectKey":"BFW","repositorySlug":"webui","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":["DECLINED"],"triggers":["MERGED"],"url":"http://x.x.x.1:8080/jenkins/job/release%20builds/buildWithParameters?token=build&BUILD_ON=buildslave3","user":"root","uuid":"973ab46e-0b70-45b5-9cab-ca9eb6bb2c8f","postContentEncoding":"NONE"},{"headers":[],"method":"GET","name":"updates-scripts","projectKey":"BFW","repositorySlug":"bfwbuild","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":[],"triggers":["APPROVED","MERGED"],"url":"http://x.x.x.1/view/maintenance/job/sync%20bfwbuild%20repo/build?token=update-scripts","uuid":"0e0f65aa-d044-4c50-be57-6ce4a8e40b90","postContentEncoding":"NONE"},{"headers":[],"method":"GET","name":"updates-scripts","projectKey":"BFW","repositorySlug":"bfwbuild","triggerIfCanMerge":"NOT_CONFLICTING","triggerIgnoreStateList":[],"triggers":["APPROVED","MERGED"],"url":"http://x.x.x.1/view/maintenance/job/sync%20bfwbuild%20repo/build?token=update-scripts","uuid":"fe42a91a-90fd-4bed-951d-c0f344b66dc0","postContentEncoding":"NONE"}]
tomasbjerre commented 7 years ago

Thanks for reporting! Should be fixed now in 3.3, open issue again if not working.

rezen commented 7 years ago

Wow, that was really fast, thanks again for the work you've put into this!