Skip to content

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

fix(agent-vault): keep descriptions on one line and match the API's rules

Scott Wilsonc0008903d5ce
diff --git a/backend/e2e-test/routes/v1/agent-vault.spec.ts b/backend/e2e-test/routes/v1/agent-vault.spec.ts
index bc41466f65..2f0de0156e 100644
--- a/backend/e2e-test/routes/v1/agent-vault.spec.ts
+++ b/backend/e2e-test/routes/v1/agent-vault.spec.ts
@@ -4922,6 +4922,27 @@ describe("Agent Vault V1 Router", async () => {
expect((JSON.parse(cleared.payload) as { proxy: { description: string | null } }).proxy.description).toBeNull();
});
+ test("a blank proxy description is stored as null, and a line break is refused", async () => {
+ const created = await inject("POST", "/api/v1/agent-vault/proxies", {
+ name: "blank-description-proxy",
+ description: " "
+ });
+ expect(created.statusCode).toBe(200);
+ const { proxy } = JSON.parse(created.payload) as { proxy: { id: string; description: string | null } };
+ expect(proxy.description).toBeNull();
+
+ const set = await inject("PATCH", `/api/v1/agent-vault/proxies/${proxy.id}`, { description: "Egress" });
+ expect(set.statusCode).toBe(200);
+ const blanked = await inject("PATCH", `/api/v1/agent-vault/proxies/${proxy.id}`, { description: "" });
+ expect(blanked.statusCode).toBe(200);
+ expect((JSON.parse(blanked.payload) as { proxy: { description: string | null } }).proxy.description).toBeNull();
+
+ const multiline = await inject("PATCH", `/api/v1/agent-vault/proxies/${proxy.id}`, {
+ description: "Egress for staging\nowned by platform"
+ });
+ expect(multiline.statusCode).toBe(422);
+ });
+
test("create and rotate both hand back the proxy token at the top level", async () => {
const created = await inject("POST", "/api/v1/agent-vault/proxies", { name: "flat-token-shape" });
expect(created.statusCode).toBe(200);
diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.ts
index 63702032b2..e07ee4d6ca 100644
--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.ts
+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.ts
@@ -113,7 +113,7 @@ export const registerAgentVaultProxyRouter = async (server: FastifyZodProvider)
projectId: req.internalAgentVaultProjectId,
event: {
type: EventType.AGENT_VAULT_PROXY_REGISTER,
- metadata: { proxyId: proxy.id, name: proxy.name }
+ metadata: { proxyId: proxy.id, name: proxy.name, description: proxy.description ?? null }
}
});
} catch (error) {
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.ts
index d8ec02e102..0c18c70604 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
@@ -50,7 +50,9 @@ export const AgentVaultDescriptionSchema = z
.string()
.trim()
.max(256, "A description can be at most 256 characters")
- .regex(AGENT_VAULT_NO_CONTROL_CHARS_RE, AGENT_VAULT_NO_CONTROL_CHARS_MESSAGE);
+ .regex(AGENT_VAULT_NO_CONTROL_CHARS_RE, AGENT_VAULT_NO_CONTROL_CHARS_MESSAGE)
+ // Blank and absent read the same, so a blank description is stored as null rather than "".
+ .transform((description) => description || null);
export const AgentVaultHostPatternSchema = hostPatternSchema.describe(AGENT_VAULT.SERVICE.hostPattern);
diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
index dba68e7432..ce75da6cfb 100644
--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-types.ts
@@ -81,7 +81,7 @@ export type TGetAccessBundleDTO = TAgentVaultProjectScoped & { accessBundleId: s
export type TCreateAccessBundleDTO = TAgentVaultProjectScoped & {
name: string;
- description?: string;
+ description?: string | null;
};
export type TUpdateAccessBundleDTO = TAgentVaultProjectScoped & {
diff --git a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-types.ts b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-types.ts
index 42ac5aa110..8a6b6e76f0 100644
--- a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-types.ts
+++ b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-types.ts
@@ -24,7 +24,7 @@ export type TListProxiesDTO = TAgentVaultProxyScoped & {
export type TCreateProxyDTO = TAgentVaultProxyScoped & {
name: string;
- description?: string;
+ description?: string | null;
trafficPolicy?: AgentVaultTrafficPolicy;
allowedHosts?: string | null;
pollInterval?: number;
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 036750157a..fbfc639f8d 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -6460,6 +6460,7 @@ interface AgentVaultProxyRegisterEvent {
metadata: {
proxyId: string;
name: string;
+ description: string | null;
};
}
diff --git a/frontend/src/components/agent-vault/AccessBundleFormDialog.tsx b/frontend/src/components/agent-vault/AccessBundleFormDialog.tsx
index 20a0ff0a99..b6720eb841 100644
--- a/frontend/src/components/agent-vault/AccessBundleFormDialog.tsx
+++ b/frontend/src/components/agent-vault/AccessBundleFormDialog.tsx
@@ -17,9 +17,9 @@ import {
FieldDescription,
FieldError,
FieldLabel,
- Input,
- TextArea
+ Input
} from "@app/components/v3";
+import { agentVaultDescriptionSchema } from "@app/helpers/agentVaultDescription";
import {
useCreateAgentVaultAccessBundle,
useUpdateAgentVaultAccessBundle
@@ -29,7 +29,7 @@ import { slugSchema } from "@app/lib/schemas";
const schema = z.object({
name: slugSchema({ max: 64, field: "Name" }),
- description: z.string().trim().max(256).optional()
+ description: agentVaultDescriptionSchema.optional()
});
type FormData = z.infer<typeof schema>;
@@ -68,10 +68,13 @@ export const AccessBundleFormDialog = ({
try {
let createdAccessBundle: TAgentVaultAccessBundle | undefined;
if (accessBundle) {
+ const nextDescription = description || null;
await updateAccessBundle.mutateAsync({
accessBundleId: accessBundle.id,
name,
- description: description || null
+ // Sent only when changed, so the update's audit event doesn't read as clearing it.
+ description:
+ nextDescription !== (accessBundle.description ?? null) ? nextDescription : undefined
});
} else {
createdAccessBundle = await createAccessBundle.mutateAsync({
@@ -127,9 +130,8 @@ export const AccessBundleFormDialog = ({
<Field>
<FieldLabel>Description</FieldLabel>
<FieldContent>
- <TextArea
+ <Input
{...field}
- rows={2}
placeholder="Paging, metrics, issue tracking"
isError={Boolean(fieldState.error)}
/>
diff --git a/frontend/src/helpers/agentVaultDescription.ts b/frontend/src/helpers/agentVaultDescription.ts
new file mode 100644
index 0000000000..9028dbea7d
--- /dev/null
+++ b/frontend/src/helpers/agentVaultDescription.ts
@@ -0,0 +1,14 @@
+import { z } from "zod";
+
+// Mirrors AgentVaultDescriptionSchema on the backend, messages included.
+// eslint-disable-next-line no-control-regex
+const NO_CONTROL_CHARS_RE = /^[^\x00-\x1f\x7f]*$/;
+
+export const agentVaultDescriptionSchema = z
+ .string()
+ .trim()
+ .max(256, "A description can be at most 256 characters")
+ .regex(
+ NO_CONTROL_CHARS_RE,
+ "This can't contain line breaks or other control characters. Check for a stray newline if you pasted it."
+ );
diff --git a/frontend/src/hooks/api/agentVault/mutations.tsx b/frontend/src/hooks/api/agentVault/mutations.tsx
index 24c5cd4d8f..1ecbaab8d3 100644
--- a/frontend/src/hooks/api/agentVault/mutations.tsx
+++ b/frontend/src/hooks/api/agentVault/mutations.tsx
@@ -18,7 +18,6 @@ import {
TAgentVaultOauthAuthorization,
TAgentVaultPersonalValues,
TAgentVaultProxy,
- TAgentVaultProxySettingsDTO,
TAgentVaultProxyWithToken,
TAgentVaultService,
TAgentVaultSession,
@@ -29,6 +28,7 @@ import {
TCreateAgentVaultAccessBundleDTO,
TCreateAgentVaultOauthAuthorizationDTO,
TCreateAgentVaultOauthAuthorizationResponse,
+ TCreateAgentVaultProxyDTO,
TCreateAgentVaultServiceDTO,
TCreateAgentVaultSessionDTO,
TCreateAgentVaultVariableDTO,
@@ -36,6 +36,7 @@ import {
TSetAgentVaultPersonalValuesDTO,
TUpdateAgentVaultAccessBundleDTO,
TUpdateAgentVaultMemberRolesDTO,
+ TUpdateAgentVaultProxyDTO,
TUpdateAgentVaultServiceDTO,
TUpdateAgentVaultSessionLabelDTO,
TUpdateAgentVaultSessionLogSettingsDTO,
@@ -270,7 +271,7 @@ export const useCreateAgentVaultProxy = () => {
const { currentOrg } = useOrganization();
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async (params: TAgentVaultProxySettingsDTO) => {
+ mutationFn: async (params: TCreateAgentVaultProxyDTO) => {
const { data } = await apiRequest.post<TAgentVaultProxyWithToken>(
"/api/v1/agent-vault/proxies",
params
@@ -287,10 +288,7 @@ export const useUpdateAgentVaultProxy = () => {
const { currentOrg } = useOrganization();
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async ({
- proxyId,
- ...params
- }: Partial<TAgentVaultProxySettingsDTO> & { proxyId: string }) => {
+ mutationFn: async ({ proxyId, ...params }: TUpdateAgentVaultProxyDTO) => {
const { data } = await apiRequest.patch<{ proxy: TAgentVaultProxy }>(
`/api/v1/agent-vault/proxies/${proxyId}`,
params
diff --git a/frontend/src/hooks/api/agentVault/types.ts b/frontend/src/hooks/api/agentVault/types.ts
index f1e586910b..ee09a4bb51 100644
--- a/frontend/src/hooks/api/agentVault/types.ts
+++ b/frontend/src/hooks/api/agentVault/types.ts
@@ -413,12 +413,20 @@ export type TUpdateAgentVaultSessionLabelDTO = {
export type TAgentVaultProxySettingsDTO = {
name: string;
- description?: string | null;
trafficPolicy?: AgentVaultTrafficPolicy;
allowedHosts?: string | null;
pollInterval?: number;
};
+export type TCreateAgentVaultProxyDTO = TAgentVaultProxySettingsDTO & {
+ description?: string;
+};
+
+export type TUpdateAgentVaultProxyDTO = Partial<TAgentVaultProxySettingsDTO> & {
+ proxyId: string;
+ description?: string | null;
+};
+
export type TAgentVaultSessionLogExternalStorage = {
type: AgentVaultSessionLogStorageType.External;
appConnectionId: string;
diff --git a/frontend/src/pages/agent-vault/AgentVaultProxiesPage/components/ProxyFormDialog.tsx b/frontend/src/pages/agent-vault/AgentVaultProxiesPage/components/ProxyFormDialog.tsx
index cf0214bb23..a5555d7e89 100644
--- a/frontend/src/pages/agent-vault/AgentVaultProxiesPage/components/ProxyFormDialog.tsx
+++ b/frontend/src/pages/agent-vault/AgentVaultProxiesPage/components/ProxyFormDialog.tsx
@@ -28,11 +28,11 @@ import {
Input,
RadioGroup,
RadioGroupItem,
- TextArea,
Tooltip,
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
+import { agentVaultDescriptionSchema } from "@app/helpers/agentVaultDescription";
import { addHostListIssues } from "@app/helpers/agentVaultHostPattern";
import {
AgentVaultTrafficPolicy,
@@ -58,7 +58,7 @@ const TRAFFIC_POLICY_CHOICES = [
const schema = z
.object({
name: slugSchema({ max: 64, field: "Name" }),
- description: z.string().trim().max(256).optional(),
+ description: agentVaultDescriptionSchema.optional(),
trafficPolicy: z.nativeEnum(AgentVaultTrafficPolicy),
allowedHosts: z.string().trim().max(1024).optional(),
// Guarded before coercion: z.coerce turns "" into 0, which would report the range error instead.
@@ -176,10 +176,12 @@ export const ProxyFormDialog = ({ isOpen, onOpenChange, proxy, onCreated }: Prop
};
if (proxy) {
+ const description = data.description || null;
await updateProxy.mutateAsync({
proxyId: proxy.id,
...payload,
- description: data.description || null
+ // Sent only when changed, so the update's audit event doesn't read as clearing it.
+ description: description !== (proxy.description ?? null) ? description : undefined
});
createNotification({ text: `Proxy "${data.name}" updated`, type: "success" });
} else {
@@ -306,9 +308,8 @@ export const ProxyFormDialog = ({ isOpen, onOpenChange, proxy, onCreated }: Prop
<Field>
<FieldLabel>Description</FieldLabel>
<FieldContent>
- <TextArea
+ <Input
{...field}
- rows={2}
placeholder="Egress for the staging cluster"
isError={Boolean(fieldState.error)}
/>