Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(dynamic-secret): surface per-item validation errors on GCP IAM token scopes

Tuan Dang71f48fbd7b63
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GcpIamInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GcpIamInputForm.tsx
index 9a12e51a78..4bdfdca738 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GcpIamInputForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/GcpIamInputForm.tsx
@@ -214,20 +214,33 @@ export const GcpIamInputForm = ({
>
<div className="space-y-2">
{fields.map((field, index) => (
- <div key={field.id} className="flex items-center space-x-2">
- <Input
- {...control.register(`provider.tokenScopes.${index}`)}
- placeholder="https://www.googleapis.com/auth/cloud-platform"
- className="grow"
- />
- <IconButton
- onClick={() => remove(index)}
- variant="outline_bg"
- ariaLabel="Remove scope"
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- </div>
+ <Controller
+ key={field.id}
+ control={control}
+ name={`provider.tokenScopes.${index}`}
+ render={({ field: itemField, fieldState: { error: itemError } }) => (
+ <FormControl
+ isError={Boolean(itemError?.message)}
+ errorText={itemError?.message}
+ className="mb-0"
+ >
+ <div className="flex items-center space-x-2">
+ <Input
+ {...itemField}
+ placeholder="https://www.googleapis.com/auth/cloud-platform"
+ className="grow"
+ />
+ <IconButton
+ onClick={() => remove(index)}
+ variant="outline_bg"
+ ariaLabel="Remove scope"
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ </FormControl>
+ )}
+ />
))}
<Button variant="outline_bg" onClick={() => append("")} type="button">
Add Scope
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGcpIamForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGcpIamForm.tsx
index ce9a71e4aa..a026bcd264 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGcpIamForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretGcpIamForm.tsx
@@ -191,20 +191,33 @@ export const EditDynamicSecretGcpIamForm = ({
>
<div className="space-y-2">
{fields.map((field, index) => (
- <div key={field.id} className="flex items-center space-x-2">
- <Input
- {...control.register(`inputs.tokenScopes.${index}`)}
- placeholder="https://www.googleapis.com/auth/cloud-platform"
- className="grow"
- />
- <IconButton
- onClick={() => remove(index)}
- variant="outline_bg"
- ariaLabel="Remove scope"
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- </div>
+ <Controller
+ key={field.id}
+ control={control}
+ name={`inputs.tokenScopes.${index}`}
+ render={({ field: itemField, fieldState: { error: itemError } }) => (
+ <FormControl
+ isError={Boolean(itemError?.message)}
+ errorText={itemError?.message}
+ className="mb-0"
+ >
+ <div className="flex items-center space-x-2">
+ <Input
+ {...itemField}
+ placeholder="https://www.googleapis.com/auth/cloud-platform"
+ className="grow"
+ />
+ <IconButton
+ onClick={() => remove(index)}
+ variant="outline_bg"
+ ariaLabel="Remove scope"
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ </FormControl>
+ )}
+ />
))}
<Button variant="outline_bg" onClick={() => append("")} type="button">
Add Scope