Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(agent-vault): address Saif's second review on personal values
Scott Wilsonc867b7a6f7fd
diff --git a/backend/e2e-test/routes/v1/agent-vault.spec.ts b/backend/e2e-test/routes/v1/agent-vault.spec.tsindex a65bebbd15..0c99225686 100644--- a/backend/e2e-test/routes/v1/agent-vault.spec.ts+++ b/backend/e2e-test/routes/v1/agent-vault.spec.ts@@ -1356,28 +1356,34 @@ describe("Agent Vault V1 Router", async () => {expect((await inject("GET", `${variablesUrl}?limit=101`)).statusCode).toBe(422);// Exact keys, so a lookup can tell a key that exists from one that only contains the text.- expect(await list("keys=GAMMA_KEY,MISSING_KEY,ALPHA_TOKEN")).toEqual({+ expect(await list("scope=global&keys=GAMMA_KEY,MISSING_KEY,ALPHA_TOKEN")).toEqual({keys: ["ALPHA_TOKEN", "GAMMA_KEY"],totalCount: 2});- expect(await list("keys=TOKEN")).toEqual({ keys: [], totalCount: 0 });- expect((await inject("GET", `${variablesUrl}?keys=lower_case`)).statusCode).toBe(422);+ expect(await list("scope=global&keys=TOKEN")).toEqual({ keys: [], totalCount: 0 });+ expect((await inject("GET", `${variablesUrl}?scope=global&keys=lower_case`)).statusCode).toBe(422);// A trailing comma's empty entry is dropped rather than refused.- expect(await list("keys=GAMMA_KEY,")).toEqual({ keys: ["GAMMA_KEY"], totalCount: 1 });+ expect(await list("scope=global&keys=GAMMA_KEY,")).toEqual({ keys: ["GAMMA_KEY"], totalCount: 1 });+ // A key can be global and personal at once, so a lookup has to name the scope.+ const unscoped = await inject("GET", `${variablesUrl}?keys=GAMMA_KEY`);+ expect(unscoped.statusCode).toBe(400);+ expect(JSON.parse(unscoped.payload).message).toContain("Send a scope with keys");});test("a lookup by keys returns every key that exists, past the default page size", async () => {const keys = Array.from({ length: 25 }, (_, index) => `LOOKUP_KEY_${String(index).padStart(2, "0")}`);await Promise.all(keys.map((key) => createVariable({ key, value: "v" })));- const res = await inject("GET", `${variablesUrl}?keys=${keys.join(",")}`);+ const res = await inject("GET", `${variablesUrl}?scope=global&keys=${keys.join(",")}`);expect(res.statusCode).toBe(200);const body = JSON.parse(res.payload) as { variables: { key: string }[]; totalCount: number };expect(body.totalCount).toBe(25);expect(body.variables.map((variable) => variable.key)).toEqual(keys);// An explicit limit still caps it.- const capped = JSON.parse((await inject("GET", `${variablesUrl}?keys=${keys.join(",")}&limit=5`)).payload) as {+ const capped = JSON.parse(+ (await inject("GET", `${variablesUrl}?scope=global&keys=${keys.join(",")}&limit=5`)).payload+ ) as {variables: unknown[];totalCount: number;};diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.tsindex 537987b266..4fc1fef268 100644--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-schemas.ts@@ -385,18 +385,22 @@ export const AgentVaultPersonalValuesSchema = z// A username follows the admin's rule for one, a token or password the admin's rule for those.export const AgentVaultPersonalValueInputSchema = z.discriminatedUnion("field", [- z.object({- field: z.literal(AgentVaultVariableReferenceField.CredentialUsername).describe(AGENT_VAULT.PERSONAL_VALUE.field),- value: acceptsVariableReferences(- z.string().trim().min(1).max(256).regex(AGENT_VAULT_NO_CONTROL_CHARS_RE, AGENT_VAULT_NO_CONTROL_CHARS_MESSAGE)- ).describe(AGENT_VAULT.PERSONAL_VALUE.value)- }),- z.object({- field: z.literal(AgentVaultVariableReferenceField.CredentialValue).describe(AGENT_VAULT.PERSONAL_VALUE.field),- value: acceptsVariableReferences(- z.string().min(1).max(8192).regex(AGENT_VAULT_NO_CONTROL_CHARS_RE, AGENT_VAULT_NO_CONTROL_CHARS_MESSAGE)- ).describe(AGENT_VAULT.PERSONAL_VALUE.value)- })+ z+ .object({+ field: z.literal(AgentVaultVariableReferenceField.CredentialUsername).describe(AGENT_VAULT.PERSONAL_VALUE.field),+ value: acceptsVariableReferences(+ z.string().trim().min(1).max(256).regex(AGENT_VAULT_NO_CONTROL_CHARS_RE, AGENT_VAULT_NO_CONTROL_CHARS_MESSAGE)+ ).describe(AGENT_VAULT.PERSONAL_VALUE.value)+ })+ .describe(JSON.stringify({ title: "Username" })),+ z+ .object({+ field: z.literal(AgentVaultVariableReferenceField.CredentialValue).describe(AGENT_VAULT.PERSONAL_VALUE.field),+ value: acceptsVariableReferences(+ z.string().min(1).max(8192).regex(AGENT_VAULT_NO_CONTROL_CHARS_RE, AGENT_VAULT_NO_CONTROL_CHARS_MESSAGE)+ ).describe(AGENT_VAULT.PERSONAL_VALUE.value)+ })+ .describe(JSON.stringify({ title: "Token or Password" }))]);const memberIdsShape = (docs: { userIds: string; machineIdentityIds: string; groupIds: string }) => ({diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.tsindex 58c71d8caa..0c9f224904 100644--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts@@ -1016,11 +1016,11 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund// member-provided has nothing stored to keep.const previousMemberFields = (service.memberProvidedFields ?? []) as TAgentVaultMemberProvidedField[];const nextMemberFields = credential ? nextMemberFieldsOf(credential, service) : null;- const credentialTypeChanged = Boolean(credential) && credential!.type !== service.credentialType;+ const credentialTypeChanged = credential !== undefined && credential.type !== service.credentialType;const memberFieldsChanged =credentialTypeChanged ||- (Boolean(credential) && !sameMemberProvidedFields(nextMemberFields, previousMemberFields));- const needsStoredSecret = Boolean(credential) && needsStoredSecretFor(credential!, service);+ (credential !== undefined && !sameMemberProvidedFields(nextMemberFields, previousMemberFields));+ const needsStoredSecret = credential !== undefined && needsStoredSecretFor(credential, service);const storedSecretCipher = needsStoredSecret ? await getProjectCipher(rest.projectId) : null;const storedSecret = storedSecretCipher? (JSON.parse(diff --git a/backend/src/ee/services/agent-vault-variable/agent-vault-variable-dal.ts b/backend/src/ee/services/agent-vault-variable/agent-vault-variable-dal.tsindex 1dcad53a00..c432caadd5 100644--- a/backend/src/ee/services/agent-vault-variable/agent-vault-variable-dal.ts+++ b/backend/src/ee/services/agent-vault-variable/agent-vault-variable-dal.ts@@ -154,6 +154,8 @@ export const agentVaultVariableDALFactory = (db: TDbClient) => {} else {void pageQuery.orderBy(`${TableName.AgentVaultVariable}.key`, orderDirection);}+ // Without a scope, a global and a personal variable can share a key, so pages need a total order.+ void pageQuery.orderBy(`${TableName.AgentVaultVariable}.id`, "asc");return { variables: (await pageQuery) as TAgentVaultVariable[], totalCount };} catch (error) {diff --git a/backend/src/ee/services/agent-vault-variable/agent-vault-variable-service.ts b/backend/src/ee/services/agent-vault-variable/agent-vault-variable-service.tsindex 12d9cead4f..82c90bd4fb 100644--- a/backend/src/ee/services/agent-vault-variable/agent-vault-variable-service.ts+++ b/backend/src/ee/services/agent-vault-variable/agent-vault-variable-service.ts@@ -225,6 +225,12 @@ export const agentVaultVariableServiceFactory = ({(await getProjectCipher(projectId)).encryptor({ plainText: Buffer.from(JSON.stringify({ value })) }).cipherTextBlob;const listVariables = async ({ projectId, ctx, scope: scopeName, limit, ...query }: TListVariablesDTO) => {+ // A key can name a global variable and one of the caller's own, so a lookup by keys has to say which.+ if (query.keys && !scopeName) {+ throw new BadRequestError({+ message: "Send a scope with keys. A key can name both a global variable and one of your own personal variables."+ });+ }const owners = await resolveListOwners({ projectId, ctx }, scopeName);const personalOwner = owners.find((owner) => owner !== null) ?? null;diff --git a/backend/src/ee/services/agent-vault/CLAUDE.md b/backend/src/ee/services/agent-vault/CLAUDE.mdindex fab877e21b..403f0a906c 100644--- a/backend/src/ee/services/agent-vault/CLAUDE.md+++ b/backend/src/ee/services/agent-vault/CLAUDE.md@@ -248,23 +248,23 @@ variables**, rows of `agent_vault_variables` with an owner, that only their ownservice's sealed secret holds only the admin's fields, so a bearer token left to members stores no secret atall and the column is NULL. Code that reads `encryptedCredential` NULL as passthrough has to check`memberProvidedFields` first.-- **One variables resource, two scopes.** `scope` on `/agent-vault/variables` (`global` or `personal`) picks the- list and is required for a new one; a list without it returns everything the caller can see (their own, plus- the global ones for an admin), and the service sheet's picker asks for `global` explicitly. Every variable read- and lock in the DAL takes an owner (`null` for global) so a global lookup never matches a personal key, and- resolve expands each kind only against its own. By id, a variable the caller may not act on is a 404, never a 403: someone else's personal one, and a- global one for a member. Global keys are unique per project (500 cap), personal ones per owner (100 cap), each- enforced by a partial unique index plus an advisory lock per project or per owner.+- **One variables resource, two scopes.** `scope` on `/agent-vault/variables` (`global` or `personal`) picks the list+ and is required for a new one; a list without it returns everything the caller can see (their own, plus the global+ ones for an admin), and the service sheet's picker asks for `global` explicitly. Every variable read and lock in+ the DAL takes an owner (`null` for global) so a global lookup never matches a personal key, and resolve expands+ each kind only against its own. By id, a variable the caller may not act on is a 404, never a 403: someone else's+ personal one, and a global one for a member. Global keys are unique per project (500 cap), personal ones per owner+ (100 cap), each enforced by a partial unique index plus an advisory lock per project or per owner.- **Everything personal is scoped to the caller, never to an id the caller sends.** No route names another actor,so an admin can't list, read or set anyone else's variables or values. The owner is a user or a machine identity(`ownerOf`); the UI only covers users for now, but resolve and the API already work for an identity's ownsessions.- **Resolve fills member fields last**: the admin's fields are expanded against global variables first, then eachpersonal value against the session actor's personal variables only, so neither is ever expanded twice and a- personal `{{KEY}}` can't reach a global variable. A service whose actor hasn't set every member-provided field- goes out with `personalValuesMissing: true` and a passthrough credential. The proxy refuses it with a 403 (CLI- change); an older proxy that ignores the flag forwards it with the service's custom headers and substitutions- but no credential, never the admin's.+ personal `{{KEY}}` can't reach a global variable. A service whose actor hasn't set every member-provided field goes+ out with `personalValuesMissing: true` and a passthrough credential. The proxy refuses it with a 403 from current+ CLIs; an older proxy that ignores the flag forwards it with the service's custom headers and substitutions but no+ credential, never the admin's.- **A save is a PATCH**: a field sent replaces that field's saved value, a field left out keeps it, and everymember-provided field must be set once it's applied. The save takes the service row `FOR SHARE` and re-checksthe fields it validated against, so an admin changing them either waits for it or makes it 409. It also takes@@ -275,15 +275,15 @@ variables**, rows of `agent_vault_variables` with an owner, that only their ownservice row: a credential type change deletes every member's values for the service, and taking a field backfrom members deletes that field's. Adding a member-provided field keeps what members saved, and they add onlythe new one.-- **Losing a bundle through Agent Vault clears what an actor saved for its services** (`clearPersonalValuesAfterRevoke`).- It runs on a bundle revoke, on removal from Agent Vault, and on a demotion from admin, for the actors named and the- members of a named group, after that change is written. It skips anyone who still holds the bundle through another- grant, and anyone who is still a project admin, since an admin reaches every bundle. Platform paths (group- removal, a lapsed role, project, org or SCIM removal) don't run it, so values can outlive the grant there and- return with a later one. They are only ever the same actor's, and resolve still checks reach. Deleting a personal- variable also clears the owner's values on bundles they no longer reach, which otherwise would hold the variable- in place with nothing able to edit them. Personal variables survive all of this, and their Used By lists only- the bundles the owner still reaches.+- **Losing a bundle through Agent Vault clears what an actor saved for its services**+ (`clearPersonalValuesAfterRevoke`). It runs on a bundle revoke, on removal from Agent Vault, and on a demotion from+ admin, for the actors named and the members of a named group, after that change is written. It skips anyone who+ still holds the bundle through another grant, and anyone who is still a project admin, since an admin reaches every+ bundle. Platform paths (group removal, a lapsed role, project, org or SCIM removal) don't run it, so values can+ outlive the grant there and return with a later one. They are only ever the same actor's, and resolve still checks+ reach. Deleting a personal variable also clears the owner's values on bundles they no longer reach, which otherwise+ would hold the variable in place with nothing able to edit them. Personal variables survive all of this, and their+ Used By lists only the bundles the owner still reaches.- Personal variables follow the global variables' reference rules: sealed text names them by id, a reference rowper personal value (`agent_vault_personal_value_references`, a deferred foreign key), the delete takes the variablerow `FOR UPDATE` and a personal values save takes the rows it references `FOR SHARE`. Used By on a variable readsdiff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 0abb09f591..6119e8016a 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -4572,7 +4572,7 @@ export const AGENT_VAULT = {orderBy: "What to sort variables by: key, or serviceCount for how many services use each one.",orderDirection: "Which way to sort: asc or desc.",search: "Match variables whose key contains this text.",- keys: "Return only the variables with these exact keys, comma-separated. Every one that exists is returned unless limit is set.",+ keys: "Return only the variables with these exact keys, comma-separated. Every one that exists is returned unless limit is set. Requires scope, since a key can name both a global variable and one of your own.",limit: "The maximum number of variables to return. Defaults to 20, or to the number of keys when keys is given.",offset: "How many variables to skip.",totalCount: "How many variables match the search, across every page.",diff --git a/docs/documentation/platform/agent-vault/access-bundles.mdx b/docs/documentation/platform/agent-vault/access-bundles.mdxindex 5ba8d3902c..51c5b47326 100644--- a/docs/documentation/platform/agent-vault/access-bundles.mdx+++ b/docs/documentation/platform/agent-vault/access-bundles.mdx@@ -80,9 +80,7 @@ To set up your personal values:Infisical never shows your personal values to anyone else, admins included.-- To change your personal values, open the service's actions menu, select **Update My Personal Values**, and enter the values you want to change (a field you leave blank keeps its saved value)+- To change your personal values, open the service's actions menu, select **Update My Personal Values**, and enter the values you want to change- To delete your personal values, select **Remove** in the same dialog, then select **Remove Personal Values**-If an admin removes you from the access bundle or from Agent Vault, Infisical deletes the personal values you set up for its services.--Machine identities can set up personal values too, through the [API](/api-reference/endpoints/agent-vault-services/set-personal-values). An identity keeps its own [personal variables](/documentation/platform/agent-vault/variables#personal-variables) the same way.+A machine identity sets up its personal values with [the set personal values endpoint](/api-reference/endpoints/agent-vault-services/set-personal-values), and keeps its own personal variables with [the create variable endpoint](/api-reference/endpoints/agent-vault-variables/create).diff --git a/docs/documentation/platform/agent-vault/services.mdx b/docs/documentation/platform/agent-vault/services.mdxindex 86ea15281a..6396b805ed 100644--- a/docs/documentation/platform/agent-vault/services.mdx+++ b/docs/documentation/platform/agent-vault/services.mdx@@ -93,13 +93,8 @@ To make a field member provided:</Step></Steps>-When you change which fields are member provided, members keep the values that still apply:--- If you make another field member provided, each member keeps their saved values and only has to add the new one-- If you stop leaving a field to members, Infisical deletes their values for that field only-<Warning>-If you change the credential type, Infisical deletes every member's personal values for the service, and each member has to set them up again.+If you change the credential type, each member has to set up their personal values for the service again.</Warning>Until a member [sets up their personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values), the proxy refuses their sessions' requests to the service with a `403` response. Requests to the bundle's other services still go through.diff --git a/docs/documentation/platform/agent-vault/sessions-cli.mdx b/docs/documentation/platform/agent-vault/sessions-cli.mdxindex 1e4afcdbb4..c5caeb0671 100644--- a/docs/documentation/platform/agent-vault/sessions-cli.mdx+++ b/docs/documentation/platform/agent-vault/sessions-cli.mdx@@ -180,7 +180,7 @@ If you've [set up session logs](/documentation/platform/agent-vault/session-logsIf the agent's requests start failing with a 403 from the proxy, such as `CONNECT tunnel failed, response 403`, the session expired before the agent finished. Set a longer `--ttl`.</Accordion><Accordion title="Requests to a service fail with "needs your personal values"">- The service is [member provided](/documentation/platform/agent-vault/services#member-provided-values), and whoever the session belongs to hasn't set up their personal values for it yet. A user sets them up under **Access Bundles**: select the bundle named in the message, then [set up the personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values). A machine identity sets them up through the [API](/api-reference/endpoints/agent-vault-services/set-personal-values). Once they're saved, the proxy picks them up within one [poll interval](/documentation/platform/agent-vault/proxies#poll-interval).+ The service [takes part of its credential from each member](/documentation/platform/agent-vault/services#member-provided-values), and whoever the session belongs to hasn't set up their personal values for it yet. A user sets them up under **Access Bundles**: select the bundle named in the message, then [set up the personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values). A machine identity sets them up with [the set personal values endpoint](/api-reference/endpoints/agent-vault-services/set-personal-values). Once they're saved, the proxy picks them up within one [poll interval](/documentation/platform/agent-vault/proxies#poll-interval).</Accordion><Accordion title="A session stays Active after the agent stopped">The CLI couldn't revoke the session, for example because the machine shut down or the process was killed with `SIGKILL`. [Revoke the session](/documentation/platform/agent-vault/sessions#revoke-a-session) on the **Sessions** page, or let it expire at the end of its `--ttl`.diff --git a/docs/documentation/platform/agent-vault/sessions.mdx b/docs/documentation/platform/agent-vault/sessions.mdxindex 801dd53f3a..2aa7c65233 100644--- a/docs/documentation/platform/agent-vault/sessions.mdx+++ b/docs/documentation/platform/agent-vault/sessions.mdx@@ -24,8 +24,6 @@ Anyone granted at least one access bundle can create a session. Admins can creat<Step>Pick the **Access Bundle** the agent should use, set a duration under **Expires**, then select **Create Session**.- If a service in the bundle still requires [your personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values), the dialog lists the service with a **Set Up** button. You can create the session before you set up your personal values, but until you do, the proxy refuses the session's requests to that service.-<Frame><img src="/images/platform/agent-vault/session-create.png" alt="The Create Session dialog with an access bundle picked and a seven day expiry" /></Frame>diff --git a/docs/documentation/platform/agent-vault/variables.mdx b/docs/documentation/platform/agent-vault/variables.mdxindex 8d68c1bd25..8b1940296c 100644--- a/docs/documentation/platform/agent-vault/variables.mdx+++ b/docs/documentation/platform/agent-vault/variables.mdx@@ -8,7 +8,7 @@ A variable is a value that you can use in any [service](/documentation/platform/When an agent sends a request, the [proxy](/documentation/platform/agent-vault/proxies) replaces each reference with the variable's value.<Info>- Only [Agent Vault admins](/documentation/platform/agent-vault/access-control#product-membership) can view and update global variables, the variables that services use. Every member, including admins, can also keep [personal variables](#personal-variables).+ Only [Agent Vault admins](/documentation/platform/agent-vault/access-control#product-membership) can view and update global variables.</Info>## Add a variable@@ -157,5 +157,5 @@ To see your personal variables, go to **Variables** in Agent Vault. If you're anYou add, update, and delete personal variables the same way as [global variables](#add-a-variable), with these limits:- You can keep up to 100 personal variables-- Your personal variable keys need to be unique among your own variables only, so one can share a key with a global variable or with another member's personal variable-- If your personal values for a service use a variable, you can't delete the variable until you change those values+- A personal variable's key only has to be unique among your own personal variables (it can match a global variable's key, or another member's)+- If your personal values for a service use a variable, you can't delete the variable until you remove it from the servicediff --git a/frontend/src/components/agent-vault/PersonalValuesDialog.tsx b/frontend/src/components/agent-vault/PersonalValuesDialog.tsxindex 50eb952004..32ae6e7968 100644--- a/frontend/src/components/agent-vault/PersonalValuesDialog.tsx+++ b/frontend/src/components/agent-vault/PersonalValuesDialog.tsx@@ -253,7 +253,7 @@ export const PersonalValuesDialog = ({ target, onOpenChange }: Props) => {})).filter(({ value }) => value.length > 0)});- createNotification({ text: `${service.name} set up`, type: "success" });+ createNotification({ text: `Personal values saved for ${service.name}`, type: "success" });onOpenChange(false);} catch {// A failed request returns a 4xx that the global request handler surfaces as a toast@@ -268,7 +268,7 @@ export const PersonalValuesDialog = ({ target, onOpenChange }: Props) => {serviceId: service.id});createNotification({- text: `Your personal values for ${service.name} were removed`,+ text: `Personal values removed for ${service.name}`,type: "success"});setIsRemoveOpen(false);diff --git a/frontend/src/components/agent-vault/nameList.test.ts b/frontend/src/components/agent-vault/nameList.test.tsdeleted file mode 100644index 833d8c6e4c..0000000000--- a/frontend/src/components/agent-vault/nameList.test.ts+++ /dev/null@@ -1,15 +0,0 @@-import { describe, expect, test } from "vitest";--import { nameList } from "./nameList";--describe("nameList", () => {- test.each([- [["a"], undefined, "a"],- [["a", "b"], undefined, "a and b"],- [["a", "b", "c"], undefined, "a, b and c"],- [["a", "b", "c", "d"], undefined, "a, b, c and 1 more"],- [["a", "b", "c"], 17, "a, b, c and 14 more"]- ])("%j of %s", (names, total, expected) => {- expect(nameList(names, total)).toBe(expected);- });-});diff --git a/frontend/src/components/agent-vault/nameList.ts b/frontend/src/components/agent-vault/nameList.tsdeleted file mode 100644index 5a4e6a433d..0000000000--- a/frontend/src/components/agent-vault/nameList.ts+++ /dev/null@@ -1,13 +0,0 @@-const NAMES_SHOWN = 3;--/**- * Names a list for a sentence: "a", "a and b", "a, b and c", and past three, "a, b, c and 4 more". `total` counts- * names a page didn't load, so a capped list still reports how many there are.- */-export const nameList = (names: string[], total = names.length) => {- const shown = names.slice(0, NAMES_SHOWN);- const more = total - shown.length;- if (more > 0) return `${shown.join(", ")} and ${more} more`;- if (shown.length <= 2) return shown.join(" and ");- return `${shown.slice(0, -1).join(", ")} and ${shown[shown.length - 1]}`;-};diff --git a/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsx b/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsxindex 03119afab2..86b8267652 100644--- a/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsx+++ b/frontend/src/components/agent-vault/service-sheet/ReviewFields.tsx@@ -53,11 +53,12 @@ const alignColumns = (rows: string[][]) => {type Props = {isUpdate: boolean;+ storedType?: AgentVaultCredentialType;/** The fields that were member-provided when the sheet opened, which have no stored value behind them. */storedMemberFields?: TAgentVaultMemberProvidedField[];};-export const ReviewFields = ({ isUpdate, storedMemberFields = [] }: Props) => {+export const ReviewFields = ({ isUpdate, storedType, storedMemberFields = [] }: Props) => {const { watch } = useFormContext<TServiceForm>();const form = watch();@@ -85,8 +86,11 @@ export const ReviewFields = ({ isUpdate, storedMemberFields = [] }: Props) => {field: TAgentVaultMemberProvidedField) => {if (form.memberProvidedFields.includes(field)) return "Set by each member";- // A field taken back from members had no value of the admin's to replace or clear.- if (!isUpdate || storedMemberFields.includes(field)) return value ? "Set" : "None";+ // Nothing of the admin's carries over to a new credential type or a field taken back from members, so there is+ // no value to replace or clear.+ if (!isUpdate || form.credentialType !== storedType || storedMemberFields.includes(field)) {+ return value ? "Set" : "None";+ }if (value === UNCHANGED_SECRET) return "Unchanged";if (value) return "Replaced";return canClear ? "Cleared" : "Unchanged";diff --git a/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx b/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsxindex c9e808b95c..5951599bf6 100644--- a/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx+++ b/frontend/src/components/agent-vault/service-sheet/ServiceSheet.tsx@@ -705,7 +705,8 @@ export const ServiceSheet = ({{current.step === ServiceStep.Review && (<ReviewFieldsisUpdate={isUpdate}- storedMemberFields={service ? storedMemberFields(service) : undefined}+ storedType={service?.credential.type}+ storedMemberFields={storedMemberFields(service)}/>)}</div>diff --git a/frontend/src/helpers/string.test.ts b/frontend/src/helpers/string.test.tsnew file mode 100644index 0000000000..0b529e70f1--- /dev/null+++ b/frontend/src/helpers/string.test.ts@@ -0,0 +1,14 @@+import { describe, expect, test } from "vitest";++import { nameList } from "./string";++describe("nameList", () => {+ test.each([+ [["a"], "a"],+ [["a", "b"], "a and b"],+ [["a", "b", "c"], "a, b and c"],+ [["a", "b", "c", "d", "e"], "a, b, c and 2 more"]+ ])("%j", (names, expected) => {+ expect(nameList(names)).toBe(expected);+ });+});diff --git a/frontend/src/helpers/string.ts b/frontend/src/helpers/string.tsindex ff12afced4..e7af4d39f0 100644--- a/frontend/src/helpers/string.ts+++ b/frontend/src/helpers/string.ts@@ -17,3 +17,14 @@ export const DistinguishedNameRegex =/^(?:(?:[a-zA-Z0-9]+=[^,+="<>#;\\\\]+)(?:(?:\\+[a-zA-Z0-9]+=[^,+="<>#;\\\\]+)*)(?:,(?:[a-zA-Z0-9]+=[^,+="<>#;\\\\]+)(?:(?:\\+[a-zA-Z0-9]+=[^,+="<>#;\\\\]+)*))*)?$/;export const UserPrincipalNameRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;++const NAMES_SHOWN = 3;++/** Names a list for a sentence: "a", "a and b", "a, b and c", and past three, "a, b, c and 4 more". */+export const nameList = (names: string[]) => {+ const shown = names.slice(0, NAMES_SHOWN);+ const more = names.length - shown.length;+ if (more > 0) return `${shown.join(", ")} and ${more} more`;+ if (shown.length <= 2) return shown.join(" and ");+ return `${shown.slice(0, -1).join(", ")} and ${shown[shown.length - 1]}`;+};diff --git a/frontend/src/pages/agent-vault/AgentVaultAccessBundlesPage/AgentVaultAccessBundlesPage.tsx b/frontend/src/pages/agent-vault/AgentVaultAccessBundlesPage/AgentVaultAccessBundlesPage.tsxindex 3517cd9403..b26c00e24a 100644--- a/frontend/src/pages/agent-vault/AgentVaultAccessBundlesPage/AgentVaultAccessBundlesPage.tsx+++ b/frontend/src/pages/agent-vault/AgentVaultAccessBundlesPage/AgentVaultAccessBundlesPage.tsx@@ -18,7 +18,6 @@ import { twMerge } from "tailwind-merge";import { AccessBundleFormDialog } from "@app/components/agent-vault/AccessBundleFormDialog";import { ManageAccessSheet } from "@app/components/agent-vault/ManageAccessSheet";-import { nameList } from "@app/components/agent-vault/nameList";import { ServiceIconStack } from "@app/components/agent-vault/ServiceIconStack";import {Alert,@@ -59,6 +58,7 @@ import {TooltipTrigger} from "@app/components/v3";import { useOrganization, useProjectPermission } from "@app/context";+import { nameList } from "@app/helpers/string";import {getUserTablePreference,PreferenceKey,