From 868d52a3457c259e007c59c168abb68425a19e00 Mon Sep 17 00:00:00 2001 From: panaaj <38519157+panaaj@users.noreply.github.com> Date: Wed, 30 Aug 2023 16:09:37 +0930 Subject: [PATCH] add additional checks for identifying provider when using setResource(). Fixes creating a new resource entry. --- src/api/resources/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 93c6fa41a..695c645a4 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -133,6 +133,10 @@ export class ResourcesApi { ) } validate.resource(resType as SignalKResourceType, resId, 'PUT', data) + } else { + if (!resId) { + return Promise.reject(new Error(`No resource id provided!`)) + } } let provider: string | undefined = undefined @@ -140,6 +144,9 @@ export class ResourcesApi { provider = this.checkForProvider(resType, providerId) } else { provider = await this.getProviderForResourceId(resType, resId) + if (!provider) { + provider = this.checkForProvider(resType) + } } if (provider) { return this.resProvider[resType]?.get(provider)?.setResource(resId, data)