Skip to content

Commit 7d23e30

Browse files
authored
Merge pull request watson-developer-cloud#497 from evenfrost/object-check
Add check for params.file to be of object type [semver patch]
2 parents 2f842c2 + e2a91f4 commit 7d23e30

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

discovery/v1.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ DiscoveryV1.prototype.addDocument = function(params, callback) {
533533
* @return {ReadableStream|undefined}
534534
*/
535535
DiscoveryV1.prototype.addJsonDocument = function(params, callback) {
536+
const fileParamType = typeof params.file;
537+
538+
if (fileParamType !== 'object') {
539+
throw new Error(`Argument error: params.file must be an object, but got ${fileParamType}.`);
540+
}
541+
536542
params = Object.assign({}, params, {
537543
file: {
538544
value: JSON.stringify(params.file),
@@ -557,6 +563,12 @@ DiscoveryV1.prototype.addJsonDocument = function(params, callback) {
557563
* @return {ReadableStream|undefined}
558564
*/
559565
DiscoveryV1.prototype.updateJsonDocument = function(params, callback) {
566+
const fileParamType = typeof params.file;
567+
568+
if (fileParamType !== 'object') {
569+
throw new Error(`Argument error: params.file must be an object, but got ${fileParamType}.`);
570+
}
571+
560572
params = Object.assign({}, params, {
561573
file: {
562574
value: JSON.stringify(params.file),

0 commit comments

Comments
 (0)