diff --git a/src/in-house-bot/deployment.ts b/src/in-house-bot/deployment.ts index 418e5256f..b717a5420 100644 --- a/src/in-house-bot/deployment.ts +++ b/src/in-house-bot/deployment.ts @@ -308,6 +308,8 @@ export class Deployment { } public getChildDeploymentWithProps = async (props={}): Promise => { + assertNoNullProps(props, `invalid filter props: ${JSON.stringify(props)}`) + return this.getChildDeployment({ filter: { EQ: props @@ -1160,3 +1162,11 @@ const getTmpSNSTopicName = ({ id, type }: { const genSID = (base: string) => `${base}${randomStringWithLength(10)}` const getTmpTopicExpirationDate = () => Date.now() + TMP_SNS_TOPIC_TTL + +const assertNoNullProps = (obj: any, msg: string) => { + for (let p in obj) { + if (obj[p] == null) { + throw new Errors.InvalidInput(msg) + } + } +} diff --git a/src/utils.ts b/src/utils.ts index 64c5e2ee6..fb9fc523f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1479,12 +1479,18 @@ export const parseStackStatusEvent = (event: any): StackStatus => { return map }, {}) + const { StackId, Timestamp, ResourceStatus, ResourceType } = props + const subscriptionArn = event.Records[0].EventSubscriptionArn + if (!(StackId && Timestamp && ResourceStatus && ResourceType && subscriptionArn)) { + throw new Errors.InvalidInput('invalid stack status event') + } + return { - stackId: props.StackId, - timestamp: new Date(props.Timestamp).getTime(), - status: props.ResourceStatus, - resourceType: props.ResourceType, - subscriptionArn: event.Records[0].EventSubscriptionArn, + stackId: StackId, + timestamp: new Date(Timestamp).getTime(), + status: ResourceStatus, + resourceType: ResourceType, + subscriptionArn, } }