Bob builder resolve libraries error (SOLVED)

I am using bob to build bundle. After i add google analytics, build is broken.

C:\Users\d954mas\odyssey-1984>java -jar ../bob(1).jar  -build-report-html bundles/report.html --archive  resolve distclean build
Infinity%Exception in thread "main" java.io.IOException: Server returned HTTP response code: 400 for URL: https://github.com/britzl/defold-googleanalytics/archive/master.zip
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
        at com.dynamo.bob.Project.resolveLibUrls(Project.java:890)
        at com.dynamo.bob.Bob.createProject(Bob.java:240)
        at com.dynamo.bob.Bob.main(Bob.java:275)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://github.com/britzl/defold-googleanalytics/archive/master.zip
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at java.net.HttpURLConnection.getResponseCode(Unknown Source)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
        at com.dynamo.bob.Project.resolveLibUrls(Project.java:870)
        ... 2 more
1 Like

Previous problem was with https. If i use http instead of https file loading work.
But i have another problem.

java -jar ../bob(1).jar  -build-report-html bundles/report.html --archive  resolve distclean build
Infinity%Exception in thread "main" com.dynamo.bob.LibraryException: The file obtained from http://github.com/britzl/defold-googleanalytics/archive/master.zip is not a valid zip file
        at com.dynamo.bob.Project.resolveLibUrls(Project.java:898)
        at com.dynamo.bob.Bob.createProject(Bob.java:240)
        at com.dynamo.bob.Bob.main(Bob.java:275)
Caused by: java.util.zip.ZipException: zip file is empty
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at com.dynamo.bob.Project.resolveLibUrls(Project.java:894)
        ... 2 more

Ok, so what if you manually download http://github.com/britzl/defold-googleanalytics/archive/master.zip from the same machine. Does it work? Can you unzip the file?

yes it work.

I understand bob problem. You download with FileUtils.copyInputStreamToFile(input,f);
But sometimes you can have 301 code. https://stackoverflow.com/questions/31730354/downloaded-file-has-0-bytes
Please fix it in next release. It broke my CI builds :slight_smile:
Jave source:

public class Main {
    public static void main(String[] args) throws IOException {
        URL url=new URL("http://github.com/britzl/defold-googleanalytics/archive/master.zip");
        File file=new File("./test.zip");
        HttpURLConnection huc = (HttpURLConnection)url.openConnection();
        int statusCode = huc.getResponseCode(); //get response code
        if (statusCode == HttpURLConnection.HTTP_MOVED_TEMP
                || statusCode == HttpURLConnection.HTTP_MOVED_PERM){ // if file is moved, then pick new URL
            url = new URL(huc.getHeaderField("Location"));
            FileUtils.copyInputStreamToFile(url.openStream(),file);
        }
       // FileUtils.copyInputStreamToFile(new BufferedInputStream(url.openConnection().getInputStream()),file);
    }
}

Any news?

Sorry, let me check.

1 Like

Ok, so you should use https, but that in itself will not be enough. It seems as if you also have to pass in --auth and --email even though they aren’t needed for resolving dependencies from GitHub. You can provide bogus values if you like:

java -jar bob.jar --email foo@bar.com --auth 12345 resolve
2 Likes

What about zero size file from github, when i use http? The problem is that github return 301 http code(file moved). Or when i add auth, everything will be ok?

bob doesn’t handle redirects, but if you look at the redirect when using http (using curl or similar) it actually redirects to the same url but with https instead. So if you use https there will be no redirect.

2 Likes

Thanks :slight_smile:

1 Like

Same issue again. What about fixing it?

Which problem of all of the ones discussed above are you currently experiencing?

Server returned HTTP response code: 400 for github
Adding email and password help. But looks like a dirty hack =)

1 Like

Yes, I agree. Added DEF-3266 to track this.

2 Likes

I was having this issue. Using the -auth -email trick worked… until just now.

 Resolving
     [java] Exception in thread "main" java.io.IOException: Server returned HTTP response code: 500 for URL: https://github.com/britzl/defold-input/archive/master.zip

I am using the latest version of bob 1.2.132 2018-06-29 16:13:36 (0941035)

I changed my -auth username to something else… and it seems to work again.

Yes, we noticed a hickup on our server with a similar message (500 from github) about the same time, and by looking at the GitHub status page, we can see that they indeed had some issues then.

4 Likes