Details
-
Bug
-
Resolution: Fixed
-
Low
-
2.12.0, 3.6.1, 3.9.1
Description
When the errors from a pre-receive hook are > 65535 characters and contains non-ASCII characters, Stash logs a java.io.UTFDataFormatException rather than returning the error to the user.
I think that the issue is that one of the error messages that is going to be presented contains non-ASCII, which may be affecting how stash calculates the length of the string:
2015-05-14 17:38:51,253 DEBUG [threadpool:thread-1] admin 1058x428x0 9jdq8q 127.0.0.1 "POST /scm/project_1/tcollector.git/git-receive-pack HTTP/1.1" com.isroot.stash.plugin.YaccHook error: refs/heads/master: 4ab418df78b7bbfe1d7c8223f59b82537352d6a1: expected committer name 'Administrator' but found 'Ulrik Holmén'
This can be 'fixed' by running:
git filter-branch -f --env-filter '
if [ "$GIT_AUTHOR_NAME" = "Ulrik Holmén" ]
then
export GIT_AUTHOR_NAME="Ulrik Holmen"
fi
if [ "$GIT_COMMITTER_NAME" = "Ulrik Holmén" ]
then
export GIT_COMMITTER_NAME="Ulrik Holmen"
fi
'
which supports this being a UTF8/ASCII issue
To reproduce (note that this is just to reproduce, but its not related to the plugin, just the error that the plugin generates)
- Install the 'yet-another-commit-checker' plugin
- Enable the hook on a repo, with the 'Require Matching Committer Email' and 'Require Matching Committer Name' options enabled
- Try to push a repository with lots of commits that won't match, including a non-ASCII committer, ie:
- git clone https://github.com/OpenTSDB/tcollector.git
- git remote set-url http://localhost:7990/stash/scm/test/tcollector.git
- git push
Expected results: A lot of errors about the commits not matching
Actual results:
$ git push
Counting objects: 1614, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (766/766), done.
Writing objects: 100% (1614/1614), 542.72 KiB | 0 bytes/s, done.
Total 1614 (delta 824), reused 1614 (delta 824)
remote: Communication breakdown with Stash.
To http://admin@localhost:7990/stash/scm/test/tcollector.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://admin@localhost:7990/stash/scm/test/tcollector.git'
and a stacktrace in the Stash logs:
java.io.UTFDataFormatException: encoded string too long: 65538 bytes
at java.io.DataOutputStream.writeUTF(DataOutputStream.java:364) ~[na:1.7.0_45]
at java.io.DataOutputStream.writeUTF(DataOutputStream.java:323) ~[na:1.7.0_45]
at com.atlassian.stash.internal.hook.SocketTransferOutput.writeInChunks(SocketTransferOutput.java:58) ~[SocketTransferOutput.class:na]
at com.atlassian.stash.internal.hook.SocketTransferOutput.writeStdErr(SocketTransferOutput.java:46) ~[SocketTransferOutput.class:na]
at com.atlassian.stash.internal.hook.DefaultHookService.writeResponse(DefaultHookService.java:320) ~[DefaultHookService.class:na]
at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:249) ~[DefaultHookService.class:na]
at com.atlassian.stash.internal.hook.DefaultHookService$2$1.run(DefaultHookService.java:205) [DefaultHookService$2$1.class:na]
at com.atlassian.stash.internal.concurrent.StateTransferringExecutor$StateTransferringRunnable.run(StateTransferringExecutor.java:73) [StateTransferringExecutor$StateTransferringRunnable.class:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_45]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [na:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
... 1 frame trimmed