saucerest-java icon indicating copy to clipboard operation
saucerest-java copied to clipboard

Exception "Illegal characters" when calling jobFailed()

Open robertarles opened this issue 7 years ago • 1 comments

The test runs (though fails) then an exception is thrown when trying to set the results on he saucelabs job.

Is this related to the code in SauceREST.java? Is there a workaround?

It seems that there is a /r/n tacked on to the "header value: Basic" The log snippet below is literal, except for the starred out chars.

    protected String encodeAuthentication() {
        String auth = username + ":" + accessKey;
        auth = "Basic " + Base64.encodeBase64String(auth.getBytes());
        return auth;
    }

SauceREST info: <groupId>com.saucelabs</groupId> <artifactId>saucerest</artifactId> 1.0.39

10-23 09:45:37.756 [com.disney.appium.common.BaseTest tearDown] Recording results to saucelabs
10-23 09:45:37.769 [com.disney.appium.common.BaseTest tearDown] Failed to record results to Saucelabs for jobId/sessionId [8dcaac8acc764170af341c508928c14e]
java.lang.IllegalArgumentException: Illegal character(s) in message header value: Basic cm9iZXJ0YXJsZXN************************************************************

	at sun.net.www.protocol.http.HttpURLConnection.checkMessageHeader(HttpURLConnection.java:541)
	at sun.net.www.protocol.http.HttpURLConnection.isExternalMessageHeaderAllowed(HttpURLConnection.java:492)
	at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3057)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:316)
	at com.saucelabs.saucerest.SauceREST.addAuthenticationProperty(SauceREST.java:542)
	at com.saucelabs.saucerest.SauceREST.updateJobInfo(SauceREST.java:562)
	at com.saucelabs.saucerest.SauceREST.jobFailed(SauceREST.java:244)
	at com.disney.appium.common.BaseTest.tearDown(BaseTest.java:203)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:707)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
	at org.testng.TestRunner.privateRun(TestRunner.java:782)
	at org.testng.TestRunner.run(TestRunner.java:632)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
	at org.testng.SuiteRunner.run(SuiteRunner.java:268)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
	at org.testng.TestNG.run(TestNG.java:1064)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:217)
	at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:92)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

robertarles avatar Oct 23 '18 16:10 robertarles

@robertarles Hi, is this still happening to you? We have version .47 now, so please can you try using the latest version?

sceiler avatar Oct 23 '20 20:10 sceiler

Should not happen with version 2.x anymore. Closing for now but please open a new issue if you still see this.

sceiler avatar Apr 28 '23 16:04 sceiler