From dab6e43d0d6d6e53fb14602f05314cd044251c54 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Tue, 28 Jul 2020 15:13:48 -0500 Subject: [PATCH] Hotfix: Remove extra JSON.stringify in Monogo update code path (#119) --- .github/workflows/ci.yml | 12 ++++++++---- src/Common/MongoProxyClient.test.ts | 4 ++-- src/Common/MongoProxyClient.ts | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fdb37b1e..fecf5c976 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,13 @@ name: CI on: push: - branches: [master] + branches: + - master + - hotfix/* + - release/* pull_request: - branches: [master] + branches: + - master jobs: compile: runs-on: ubuntu-latest @@ -184,7 +188,7 @@ jobs: NODE_TLS_REJECT_UNAUTHORIZED: 0 nuget: name: Publish Nuget - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/') needs: [lint, format, compile, build, unittest, endtoendemulator, endtoendsql, endtoendmongo] runs-on: ubuntu-latest env: @@ -208,7 +212,7 @@ jobs: path: "*.nupkg" nugetmpac: name: Publish Nuget MPAC - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/') needs: [lint, format, compile, build, unittest, endtoendemulator, endtoendsql, endtoendmongo] runs-on: ubuntu-latest env: diff --git a/src/Common/MongoProxyClient.test.ts b/src/Common/MongoProxyClient.test.ts index 2c05ce5f4..152f68bf6 100644 --- a/src/Common/MongoProxyClient.test.ts +++ b/src/Common/MongoProxyClient.test.ts @@ -173,7 +173,7 @@ describe("MongoProxyClient", () => { }); it("builds the correct URL", () => { - updateDocument(databaseId, collection, documentId, {}); + updateDocument(databaseId, collection, documentId, "{}"); expect(window.fetch).toHaveBeenCalledWith( "https://main.documentdb.ext.azure.com/api/mongo/explorer?db=testDB&coll=testCollection&resourceUrl=bardb%2FtestDB%2Fdb%2FtestCollection%2Fdocs%2FtestId&rid=testId&rtype=docs&sid=&rg=&dba=foo&pk=pk", expect.any(Object) @@ -182,7 +182,7 @@ describe("MongoProxyClient", () => { it("builds the correct proxy URL in development", () => { config.MONGO_BACKEND_ENDPOINT = "https://localhost:1234"; - updateDocument(databaseId, collection, documentId, {}); + updateDocument(databaseId, collection, documentId, "{}"); expect(window.fetch).toHaveBeenCalledWith( "https://localhost:1234/api/mongo/explorer?db=testDB&coll=testCollection&resourceUrl=bardb%2FtestDB%2Fdb%2FtestCollection%2Fdocs%2FtestId&rid=testId&rtype=docs&sid=&rg=&dba=foo&pk=pk", expect.any(Object) diff --git a/src/Common/MongoProxyClient.ts b/src/Common/MongoProxyClient.ts index 172202b77..0491c7ef0 100644 --- a/src/Common/MongoProxyClient.ts +++ b/src/Common/MongoProxyClient.ts @@ -206,7 +206,7 @@ export function updateDocument( databaseId: string, collection: Collection, documentId: DocumentId, - documentContent: unknown + documentContent: string ): Promise { const databaseAccount = CosmosClient.databaseAccount(); const resourceEndpoint = databaseAccount.properties.mongoEndpoint || databaseAccount.properties.documentEndpoint; @@ -230,7 +230,7 @@ export function updateDocument( return window .fetch(`${endpoint}?${queryString.stringify(params)}`, { method: "PUT", - body: JSON.stringify(documentContent), + body: documentContent, headers: { ...defaultHeaders, ...authHeaders(),