diff --git a/harness/features/allFeatures.cloud.test.ts b/harness/features/allFeatures.cloud.test.ts index 40b1bf74..35aba2f0 100644 --- a/harness/features/allFeatures.cloud.test.ts +++ b/harness/features/allFeatures.cloud.test.ts @@ -70,8 +70,7 @@ describe('allFeatures Tests - Cloud', () => { }) }) - // TODO DVC-5954 investigate why these were failing on the SDKs - it.skip('should throw if features request fails on invalid sdk key', async () => { + it('should throw if features request fails on invalid sdk key', async () => { scope .post(`/client/${testClient.clientId}/v1/features`) .reply(401, { message: 'Invalid sdk key' }) diff --git a/harness/features/initialize.local.test.ts b/harness/features/initialize.local.test.ts index 4b63f969..b8efa64b 100644 --- a/harness/features/initialize.local.test.ts +++ b/harness/features/initialize.local.test.ts @@ -68,8 +68,7 @@ describe('Initialize Tests - Local', () => { await testClient.createClient(true, { configPollingIntervalMS: 10000 }) }) - // TODO DVC-6016 investigate why these were failing on the nodeJS SDK - it.skip('stops the polling interval when the sdk key is invalid and cdn responds 403,' + + it('stops the polling interval when the sdk key is invalid and cdn responds 403,' + ' throws error', async () => { const testClient = new LocalTestClient(name) @@ -79,13 +78,12 @@ describe('Initialize Tests - Local', () => { const response = await testClient.createClient(true, { configPollingIntervalMS: 1000 }, testClient.sdkKey, true) - const { exception } = await response.json() + const { asyncError } = await response.json() expectErrorMessageToBe( - exception, + asyncError, 'Invalid environment key provided. Please call initialize with a valid server environment key' ) - }) it('fetches config again after 3 seconds when config polling interval is overriden', async () => { @@ -158,7 +156,7 @@ describe('Initialize Tests - Local', () => { scope .get(`/client/${testClient.clientId}/config/v1/server/${testClient.sdkKey}.json`) - .reply(200, "I'm not JSON!") + .reply(200, 'I\'m not JSON!') await testClient.createClient(true, { configPollingIntervalMS: 1000 }) @@ -180,7 +178,7 @@ describe('Initialize Tests - Local', () => { scope .get(`/client/${testClient.clientId}/config/v1/server/${testClient.sdkKey}.json`) - .reply(200, "{\"snatch_movie_quote\": \"d'ya like dags?\"}") + .reply(200, '{"snatch_movie_quote": "d\'ya like dags?"}') await testClient.createClient(true, { configPollingIntervalMS: 1000 }) diff --git a/harness/features/variable.cloud.test.ts b/harness/features/variable.cloud.test.ts index b276ae57..6b51e421 100644 --- a/harness/features/variable.cloud.test.ts +++ b/harness/features/variable.cloud.test.ts @@ -48,6 +48,7 @@ describe('Variable Tests - Cloud', () => { // from the proxy server expectErrorMessageToBe(error.asyncError, 'Missing parameter: key') }) + // TODO DVC-5954 investigate why these were failing on the SDKs it.skip('will throw error if variable called with invalid sdk key', async () => { scope diff --git a/proxies/dotnet/Controllers/Client.cs b/proxies/dotnet/Controllers/Client.cs index 8c0eaff3..ec779d45 100644 --- a/proxies/dotnet/Controllers/Client.cs +++ b/proxies/dotnet/Controllers/Client.cs @@ -127,10 +127,15 @@ public async Task Post(ClientRequestBody ClientBody) .SetLogger(LoggerFactory.Create(builder => builder.AddConsole())) .Build(); + try { await task; if (eventArgs != null && !eventArgs.Success) { throw eventArgs.Errors[0]; } + } catch (Exception e) { + Response.StatusCode = 200; + return new { asyncError = e.Message }; + } } else { DataStore.LocalClients[ClientBody.ClientId] = new DVCLocalClientBuilder() .SetEnvironmentKey(ClientBody.SdkKey) diff --git a/proxies/go/handler_client.go b/proxies/go/handler_client.go index 6426760a..e26366ce 100644 --- a/proxies/go/handler_client.go +++ b/proxies/go/handler_client.go @@ -62,7 +62,11 @@ func clientHandler(w http.ResponseWriter, r *http.Request) { client, err := devcycle.NewDVCClient(reqBody.SdkKey, &options) if err != nil { - res.Exception = err.Error() + if reqBody.WaitForInitialization { + res.AsyncError = err.Error() + } else { + res.Exception = err.Error() + } w.WriteHeader(http.StatusOK) } else { res.Message = "success"