Tag: Errors

Code Tips

Git Error : (does not point to a valid object)

A friend of mine IMed me the other day to ask if I had ever seen an error like the one below:

error: unable to find e291a84831b445ba982539cc63a418126f0b5364
error: refs/heads/master does not point to a valid object!
fatal: Couldn't find remote ref master
fatal: The remote end hung up unexpectedly

I had not, but it seemed plain enough. It appeared that the head of the master branch was pointing to a commit that didn’t actually exist in the repository. I don’t know for sure how this happened, but my friend’s team suspected a disrupted internet connection on push as one theory.

I Googled the error and found suggestions like “make a new remote” and “clone to a new branch, push, delete master, rename new branch”. This seemed like just too much work. There had to be an easier solution.

I was unable to clone the remote to my own machine (I got that same error on trying) and the team was in another state, so – short of a screensharing session – I couldn’t easily work with them on the problem.

I had the developer who had done the last known valid commit before this error send me the most recent 5 items output from the “git log” command and got the following (edited for privacy):

commit b65f24a64e78b38d193aa545d7b184fe26330a4c
Author: Joe Developer <joed@somewhere.com>
Date:   Fri Jul 27 10:05:53 2012 -0400

    Moved foo.jar to libs folder

commit 32b15424509881760667a77b615cc91e8e31afb9
Author: Joe Developer <joed@somewhere.com>
Date:   Thu Jul 26 21:45:46 2012 -0400

    Load swf files

commit bfac8d86c20ebbcac22af4e599e5815b0586f3d0
Author: Joe Developer <joed@somewhere.com>
Date:   Thu Jul 26 19:18:25 2012 -0400

    Navigation bug fixes

commit 60c5ff87435861157e56d948e09c63ad2f4db520
Author: Jane Developer <janed@somewhere.com>
Date:   Thu Jul 26 15:52:36 2012 -0400

    post merge

commit 1a97d137a51c6cd34825e4c9bc705620dfff7712
Author: Jane Developer <janed@somewhere.com>
Date:   Thu Jul 26 15:24:40 2012 -0400

    initial commit

Because Git is based in the file system, I could literally navigate to the remote file system and go to the ProjectName.git folder and into the refs/heads/ folder and find the master file (no extension). Inside was one string, the offending e291a84831b445ba982539cc63a418126f0b5364. I just replaced that string with the hash of the latest valid commit – b65f24a64e78b38d193aa545d7b184fe26330a4c – and then saved.

After that, I could clone the repo and the developers could pull, merge, and push their own changes. They were using DropBox in this instance as a “poor man’s remote” and upon further reflection, I have to wonder if that is what caused the conflict. Perhaps there was a problem with DropBox syncing all of the files and maybe a race condition at some point that resulted in a corruption? I know DropBox isn’t a perfect “remote server” solution, but a lot of people use it for certain circumstances, so this might be something to look out for.

If anyone else has seen this error and has a better fix than the one described here, then please leave a comment and let me know.

Errors

Rails Install Issue

So, I am making a serious go of learning Rails. I have installed it on my Vista machine before, but never really given it a go. So, now that I’ve got a Mac, I decided to try to learn Rails on it. I downloaded the Ruby One-Click Installer and installed it. Per its suggestion, I ran

sudo gem install rails

Then, I got this error

Bulk updating Gem source index for: 
http://gems.rubyforge.org ERROR:  
While executing gem ... (Gem::GemNotFoundException)     
Could not find rails (> 0) in any repository

I did some Googling and found out that I had to just run this code

sudo gem update

and select the correct packages to include. Then, I just reran

sudo gem install rails

and I was money in the bank.

I hope this helps anyone else who encounters the same issue. Now, on to working through some tutorials.

Code Tips

WCF Service Error

I was modifying a service last night and I got this error when I hit one of the two endpoints of the service.
The server was unable to process the request due to an internal error...
For search engines (and anyone having a hard time reading the image), it says:

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs

The other endpoint on my service was unaffected. Usually when I do something stupid, I get the “Yellow Screen of Death” the first time I try to reach my service due to an improper web.config or some other easily correctable thing. This was the first time that I had seen this.

I did some Googling and found out specifically how to get the “real” error message. I had to change my serviceDebug tag in my service’s web.config (located in system.ServiceModel/behaviors)

 <serviceBehaviors>
        <behavior name="PeteOnSoftware.SampleService_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
</serviceBehaviors>

This gave me a much more helpful message telling me that one of the elements in one of my request objects had already been defined (name and type were the defining factors) in another existing request.

There were two fixes for this. Once was a “hack” in my opinion and the other was the “correct” solution. The hack was to turn off metadata exchange on that endpoint (my particular error was related to generating the WSDL). To do that, I would have set the

<serviceMetadata httpGetEnabled="true"/>

to

<serviceMetadata httpGetEnabled="false"/>

and remove this line from beside my endpoint definition.

<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />

That would prevent developers from inside the company from generating proxy classes automatically with svcutil.exe. I didn’t want that at all.

What I did instead was to rename the element to something that made more sense anyway. This time when I built, the endpoint came up with no problem and the link to the WSDL returned the proper XML that developers would need to “reproxy”. Problem solved and lesson of the includeExceptionDetailInFaults learned!