Skip to content

Commit

Permalink
SK-1621: fix parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
“amith-skyflow” committed Oct 23, 2024
1 parent d49a85c commit 3e3cce3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/vault/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class VaultClient {

private handleJsonError(err: any, data: any, requestId: string, reject: Function) {
try {
let description = JSON.parse(JSON.stringify(data));
let description = data;
const statusCode = description?.error?.http_status;
const grpcCode = description?.error?.grpc_code;
const details = description?.error?.details;
Expand All @@ -144,7 +144,7 @@ class VaultClient {
}

private handleGenericError(err: any, requestId: string, reject: Function) {
const description = errorMessages.ERROR_OCCURRED;
const description = err?.message || errorMessages.ERROR_OCCURRED;
this.logAndRejectError(description, err, requestId, reject);
}

Expand Down
4 changes: 2 additions & 2 deletions src/vault/controller/vault/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class VaultController {
};

if (!records || !Array.isArray(records) || records.length === 0) {
return new InsertResponse({ errors: [] });
return new InsertResponse({ insertedFields:[], errors: [] });
}

records.forEach((record, index) => {
Expand Down Expand Up @@ -132,7 +132,7 @@ class VaultController {
this.client.initAPI(authInfo, requestType);
apiCall({ headers: { ...sdkHeaders } })
.then((response: any) => {
const data = JSON.parse(JSON.stringify(response.data));
const data = response.data;
printLog(logs.infoLogs[`${requestType}_REQUEST_RESOLVED`], MessageType.LOG, this.client.getLogLevel());
switch (requestType) {
case TYPES.INSERT:
Expand Down
4 changes: 2 additions & 2 deletions src/vault/model/response/insert/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { insertResponseType } from "../../../types";
class InsertResponse {

//fields
insertedFields?: Array<insertResponseType>;
insertedFields: Array<insertResponseType>;

errors?: object;

constructor({ insertedFields, errors }: { insertedFields?: Array<insertResponseType>, errors?: object }) {
constructor({ insertedFields, errors }: { insertedFields: Array<insertResponseType>, errors?: object }) {
this.insertedFields = insertedFields;
this.errors = errors;
}
Expand Down
4 changes: 2 additions & 2 deletions test/vault/controller/vault.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ describe('VaultController insert method', () => {
const response = await vaultController.insert(mockRequest, mockOptions);

expect(mockVaultClient.vaultAPI.recordServiceBatchOperation).toHaveBeenCalled();
expect(response.insertedFields).toBe(undefined);
expect(response.insertedFields).toStrictEqual([]);
});

test('should reject insert records with batch insert', async () => {
Expand All @@ -316,7 +316,7 @@ describe('VaultController insert method', () => {
const response = await vaultController.insert(mockRequest, mockOptions);

expect(mockVaultClient.vaultAPI.recordServiceBatchOperation).toHaveBeenCalled();
expect(response.insertedFields).toBe(undefined);
expect(response.insertedFields).toStrictEqual([]);
});

test('should handle validation errors', async () => {
Expand Down

0 comments on commit 3e3cce3

Please sign in to comment.