It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

What does "Unexpected output; expected a 'commit' object" mean, for a stash hook?

What does the error

Unexpected output; expected a 'commit' object


I've created a Stash pre-commit hook. When I try to perform a commit, with my hook enabled, I get

Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 271 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Hook com.vodori.hook.PepperFEProtectionHook failed. Error: 
remote: An error occurred while executing an external process: [refs/heads/master]: Unexpected output; expected a 'commit' object
To http://admin@dancrumb-latitude-e6520:7990/stash/scm/project_1/rep_1.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://admin@dancrumb-latitude-e6520:7990/stash/scm/project_1/rep_1.git'

Clearly, there's an issue with my hook, but I can't find any docs that indicate what that error means, so I don't really know where to start my debug.

Here's my actual code:

public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse) {
        Repository repo = context.getRepository();
        Collection<String> changeIDs = new ArrayList<String>(refChanges.size());
        for(RefChange refChange: refChanges) {
        DetailedChangesetsRequest dcr = new DetailedChangesetsRequest.Builder(repo)
        PageRequest pr = new PageRequestImpl(0,9999);
        Page<DetailedChangeset> pg =  historyService.getDetailedChangesets(dcr,pr);
        for (DetailedChangeset dcs: pg.getValues()) {
            for(Change c: dcs.getChanges().getValues()) {
                if(c.getType() == ChangeType.ADD) {
                    String changePath = c.getPath().toString();
                    if(changePath.contains("pepper/pepper") || changePath.contains("pepper/vodori")) {
                        hookResponse.out().println("Kicked it because of " +changePath);
                        return false;

        return true;

Not asking someone to fix it for me... just help me find the end of the thread so that I can start pulling :)

1 answer

1 accepted

1 vote
Answer accepted

I should be using


In line 5... that's the change hash... the refId is "refs/heads/master"

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted yesterday in Industry Groups

Upcoming Team Tour Government Symposium in Washington D.C.

Calling all Community members from the Washington D.C. area! Atlassian’s Team Tour is heading to your city to host a Government Symposium on May 1st. Join our team and other government agencies to le...

14 views 0 1
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you