fix: Prevent workflow breaking when credential type is unknown (#6923)

This commit is contained in:
Mutasem Aldmour
2023-08-14 14:55:38 +02:00
committed by GitHub
parent 297c3c91f2
commit e83b93f293
8 changed files with 51 additions and 60 deletions

View File

@@ -291,14 +291,14 @@ export default defineComponent({
});
},
credentialTypesNodeDescription(): INodeCredentialDescription[] {
const node = this.node as INodeUi;
const node = this.node;
const credType = this.credentialsStore.getCredentialTypeByName(this.overrideCredType);
if (credType) return [credType];
const activeNodeType = this.nodeTypesStore.getNodeType(node.type, node.typeVersion);
if (activeNodeType && activeNodeType.credentials) {
if (activeNodeType?.credentials) {
return activeNodeType.credentials;
}
@@ -308,11 +308,12 @@ export default defineComponent({
const returnData: {
[key: string]: string;
} = {};
let credentialType: ICredentialType | null;
let credentialType: ICredentialType | undefined;
for (const credentialTypeName of this.credentialTypesNode) {
credentialType = this.credentialsStore.getCredentialTypeByName(credentialTypeName);
returnData[credentialTypeName] =
credentialType !== null ? credentialType.displayName : credentialTypeName;
returnData[credentialTypeName] = credentialType
? credentialType.displayName
: credentialTypeName;
}
return returnData;
},
@@ -347,7 +348,7 @@ export default defineComponent({
options = options.concat(
this.credentialsStore.allUsableCredentialsByType[type].map((option: any) => ({
...option,
typeDisplayName: this.credentialsStore.getCredentialTypeByName(type).displayName,
typeDisplayName: this.credentialsStore.getCredentialTypeByName(type)?.displayName,
})),
);
});
@@ -436,10 +437,9 @@ export default defineComponent({
const selectedCredentials = this.credentialsStore.getCredentialById(credentialId);
const selectedCredentialsType = this.showAll ? selectedCredentials.type : credentialType;
const oldCredentials =
this.node.credentials && this.node.credentials[selectedCredentialsType]
? this.node.credentials[selectedCredentialsType]
: {};
const oldCredentials = this.node.credentials?.[selectedCredentialsType]
? this.node.credentials[selectedCredentialsType]
: {};
const selected = { id: selectedCredentials.id, name: selectedCredentials.name };
@@ -513,9 +513,9 @@ export default defineComponent({
},
getIssues(credentialTypeName: string): string[] {
const node = this.node as INodeUi;
const node = this.node;
if (node.issues === undefined || node.issues.credentials === undefined) {
if (node.issues?.credentials === undefined) {
return [];
}
@@ -526,11 +526,7 @@ export default defineComponent({
},
isCredentialExisting(credentialType: string): boolean {
if (
!this.node.credentials ||
!this.node.credentials[credentialType] ||
!this.node.credentials[credentialType].id
) {
if (!this.node.credentials?.[credentialType]?.id) {
return false;
}
const { id } = this.node.credentials[credentialType];