Split connector extra settings per credential path
Registration.ExtraSettings was a single flat list, but the API-key and client-credentials connect dialogs need different fields whenever a provider offers both paths, because a different create resolver and a different driver sits behind each. Replace it with APIKeyExtraSettings and ClientCredentialsExtraSettings, and split the GraphQL surface to match so a client cannot render one path's settings on the other. This fixes two connectors that could not be connected at all. 1Password declared accountId and region only, which are the client-credentials shape. The API-key dialog therefore rendered those two fields, mapAPIKeyExtraSettingToField returned nil for both so buildExtraFields discarded them, and the SCIM-bridge driver failed on an empty SCIMBridgeURL. The console already mapped scimBridgeUrl, but no registration declared that key, so the branch was dead. It now declares scimBridgeUrl on the API-key path and accountId + region on client credentials. Langfuse declared baseUrl as required, but mapAPIKeyExtraSettingToField had no LANGFUSE case, so buildExtraFields dropped the value the customer typed and the mutation failed with "langfuseBaseUrl is required". Every other extra-settings provider had a case. The GraphQL input field, the settings struct, the probe builder and the driver were all already correct; only the console mapping was missing. buildExtraFields now takes the settings list explicitly instead of reading it off the provider, so each dialog passes its own path's list and cannot silently iterate the other one. Register rejects a settings list for a path the provider does not offer, and an empty or duplicate setting key within one list. A key repeated across the two lists is allowed: that is how a dual-path provider declares a setting both dialogs need. The new resolver tests walk the whole chain the console walks, from the key a Registration declares through the mutation input field to the persisted settings struct, so a key renamed on one side and not the other fails in CI instead of at connect time. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -58,7 +58,12 @@ export const addAccessReviewSourceDialogConnectorProviderInfoFragment = graphql`
|
||||
apiKeyManaged
|
||||
clientCredentialsSupported
|
||||
oauth2Scopes
|
||||
extraSettings {
|
||||
apiKeyExtraSettings {
|
||||
key
|
||||
label
|
||||
required
|
||||
}
|
||||
clientCredentialsExtraSettings {
|
||||
key
|
||||
label
|
||||
required
|
||||
|
||||
@@ -196,7 +196,7 @@ export function APIKeyConnectorDialog({
|
||||
return;
|
||||
}
|
||||
|
||||
const requiredSettings = provider.extraSettings.filter(s => s.required);
|
||||
const requiredSettings = provider.apiKeyExtraSettings.filter(s => s.required);
|
||||
if (!hasRequiredExtraSettings(requiredSettings, extraSettingValues)) {
|
||||
return;
|
||||
}
|
||||
@@ -204,7 +204,8 @@ export function APIKeyConnectorDialog({
|
||||
setIsConnectingAPIKey(true);
|
||||
|
||||
const extraFields = buildExtraFields(
|
||||
provider,
|
||||
provider.provider,
|
||||
provider.apiKeyExtraSettings,
|
||||
extraSettingValues,
|
||||
mapAPIKeyExtraSettingToField,
|
||||
);
|
||||
@@ -285,7 +286,7 @@ export function APIKeyConnectorDialog({
|
||||
);
|
||||
}
|
||||
|
||||
return provider.extraSettings.map((setting) => {
|
||||
return provider.apiKeyExtraSettings.map((setting) => {
|
||||
const value = extraSettingValues[setting.key] ?? "";
|
||||
return (
|
||||
<Field
|
||||
@@ -307,7 +308,7 @@ export function APIKeyConnectorDialog({
|
||||
|| isPostHogDeploymentSelected(extraSettingValues);
|
||||
|
||||
const apiKeyExtraSettingsValid = provider
|
||||
? hasRequiredExtraSettings(provider.extraSettings, extraSettingValues)
|
||||
? hasRequiredExtraSettings(provider.apiKeyExtraSettings, extraSettingValues)
|
||||
: true;
|
||||
|
||||
return (
|
||||
|
||||
@@ -109,7 +109,7 @@ export function ClientCredentialsConnectorDialog({
|
||||
return;
|
||||
}
|
||||
|
||||
const requiredSettings = provider.extraSettings.filter(s => s.required);
|
||||
const requiredSettings = provider.clientCredentialsExtraSettings.filter(s => s.required);
|
||||
if (!hasRequiredExtraSettings(requiredSettings, clientCredentialsExtraValues)) {
|
||||
return;
|
||||
}
|
||||
@@ -117,7 +117,8 @@ export function ClientCredentialsConnectorDialog({
|
||||
setIsConnectingClientCredentials(true);
|
||||
|
||||
const extraFields = buildExtraFields(
|
||||
provider,
|
||||
provider.provider,
|
||||
provider.clientCredentialsExtraSettings,
|
||||
clientCredentialsExtraValues,
|
||||
mapClientCredentialsExtraSettingToField,
|
||||
);
|
||||
@@ -173,7 +174,7 @@ export function ClientCredentialsConnectorDialog({
|
||||
};
|
||||
|
||||
const clientCredentialsExtraSettingsValid = provider
|
||||
? hasRequiredExtraSettings(provider.extraSettings, clientCredentialsExtraValues)
|
||||
? hasRequiredExtraSettings(provider.clientCredentialsExtraSettings, clientCredentialsExtraValues)
|
||||
: true;
|
||||
|
||||
return (
|
||||
@@ -232,7 +233,7 @@ export function ClientCredentialsConnectorDialog({
|
||||
value={scope}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setScope(e.target.value)}
|
||||
/>
|
||||
{provider?.extraSettings.map(setting =>
|
||||
{provider?.clientCredentialsExtraSettings.map(setting =>
|
||||
setting.key === "region"
|
||||
? (
|
||||
<div key={setting.key} className="space-y-1.5">
|
||||
|
||||
@@ -55,6 +55,9 @@ export function mapAPIKeyExtraSettingToField(
|
||||
case "SIGNOZ":
|
||||
if (settingKey === "baseUrl") return "signozBaseUrl";
|
||||
break;
|
||||
case "LANGFUSE":
|
||||
if (settingKey === "baseUrl") return "langfuseBaseUrl";
|
||||
break;
|
||||
case "ONE_PASSWORD":
|
||||
if (settingKey === "scimBridgeUrl") return "onePasswordScimBridgeUrl";
|
||||
break;
|
||||
@@ -115,22 +118,25 @@ export function hasRequiredExtraSettings(
|
||||
.every(s => values[s.key]?.trim());
|
||||
}
|
||||
|
||||
// buildExtraFields flattens a provider's extra settings into the input-field map
|
||||
// the create mutations expect: each non-empty, trimmed value keyed by its
|
||||
// provider-specific input field name (via mapFn), skipping settings that map to
|
||||
// nothing. Shared by the API-key and client-credentials dialogs.
|
||||
// buildExtraFields flattens one connect path's extra settings into the
|
||||
// input-field map that path's create mutation expects: each non-empty, trimmed
|
||||
// value keyed by its provider-specific input field name (via mapFn), skipping
|
||||
// settings that map to nothing. Each dialog passes the settings list for its own
|
||||
// path together with the matching mapFn — a provider offering both paths
|
||||
// (1Password) declares different settings on each.
|
||||
export function buildExtraFields(
|
||||
provider: ProviderInfo,
|
||||
provider: string,
|
||||
settings: ReadonlyArray<{ readonly key: string }>,
|
||||
values: Record<string, string>,
|
||||
mapFn: (provider: string, settingKey: string) => string | null,
|
||||
): Record<string, string> {
|
||||
const extraFields: Record<string, string> = {};
|
||||
for (const setting of provider.extraSettings) {
|
||||
for (const setting of settings) {
|
||||
const value = values[setting.key]?.trim();
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
const fieldName = mapFn(provider.provider, setting.key);
|
||||
const fieldName = mapFn(provider, setting.key);
|
||||
if (fieldName) {
|
||||
extraFields[fieldName] = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user