Skip to content

Commit

Permalink
fix(frontend): Unbreak credentials input on single-provider blocks (v…
Browse files Browse the repository at this point in the history
…ol. 2)

Fix bad condition introduced in aaa0b79 (#8636) to resolve #8635
  • Loading branch information
Pwuts committed Nov 13, 2024
1 parent aaa0b79 commit ef3f7aa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions autogpt_platform/frontend/src/hooks/useCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,20 @@ export default function useCredentials(): CredentialsData | null {
]) ||
null;

if (
!discriminatorValue &&
credentialsSchema.credentials_provider.length > 1
) {
throw new Error("Multi-provider credential input requires discriminator!");
let providerName: CredentialsProviderName;
if (credentialsSchema.credentials_provider.length > 1) {
if (!credentialsSchema.discriminator) {
throw new Error(
"Multi-provider credential input requires discriminator!",
);
}
if (!discriminatorValue) {
return null;
}
providerName = discriminatorValue;
} else {
providerName = credentialsSchema.credentials_provider[0];
}

const providerName =
discriminatorValue || credentialsSchema.credentials_provider[0];
const provider = allProviders ? allProviders[providerName] : null;

// If block input schema doesn't have credentials, return null
Expand Down

0 comments on commit ef3f7aa

Please sign in to comment.