Skip to content

Commit

Permalink
fix: don't send error string from azure storage on the wire (#1196)
Browse files Browse the repository at this point in the history
* don't send error string from azure storage on the wire

* concatenate status code

* fix typo and update unit test
  • Loading branch information
vishnureddy17 authored Jul 21, 2023
1 parent 450c672 commit aef9997
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion device/core/src/blob_upload/blob_upload_result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BlobUploadResult {
let uploadResult: BlobUploadResult;
if (err) {
const statusCode = ((Object.prototype.hasOwnProperty.call(err, 'statusCode')) ? (err.statusCode) : (-1));
const statusDescription = ((Object.prototype.hasOwnProperty.call(err, 'response')) ? (err.response) : (err.message));
const statusDescription = `Failed to upload to blob${statusCode === -1 ? '' : `. Status code: ${statusCode}`}`;
/*Codes_SRS_NODE_DEVICE_BLOB_UPLOAD_RESULT_41_002: [If `err` is not `null`, the `BlobUploadResult` shall have the `isSuccess` property set to `false`]*/
uploadResult = new BlobUploadResult(false, statusCode, statusDescription);
} else {
Expand Down
2 changes: 1 addition & 1 deletion device/core/test/blob_upload/_blob_upload_result_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('BlobUploadResult', function () {
let result = BlobUploadResult.fromAzureStorageCallbackArgs(new Error(testBody), null);
assert.isFalse(result.isSuccess);
assert.equal(result.statusCode, -1);
assert.equal(result.statusDescription, testBody);
assert.equal(result.statusDescription, "Failed to upload to blob");
});

/*Tests_SRS_NODE_DEVICE_BLOB_UPLOAD_RESULT_41_003: [If `err` is null but `uploadResponse` is provided, and `uploadResponse.ErrorCode` is not null, `BlobUploadResult` shall have the `isSuccess` property set to `false`]*/
Expand Down

0 comments on commit aef9997

Please sign in to comment.