Skip to content

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

fix(agent-vault): retry a key lookup dropped by a variable change

Scott Wilson508d5d6437af
diff --git a/frontend/src/hooks/api/agentVault/queries.tsx b/frontend/src/hooks/api/agentVault/queries.tsx
index a33f5f6f92..ec752321dd 100644
--- a/frontend/src/hooks/api/agentVault/queries.tsx
+++ b/frontend/src/hooks/api/agentVault/queries.tsx
@@ -613,10 +613,17 @@ export const useAgentVaultVariableKeyStatus = (keys: readonly string[], enabled
})
.sort();
+ // The change count is part of the key, so a change starts a new lookup instead of joining one still in flight,
+ // whose answers that change has made stale.
+ const changeCount = variableChangeCounts.get(currentOrg.id) ?? 0;
useQuery({
- queryKey: [...agentVaultKeys.variables(currentOrg.id), "key-status-batch", unchecked],
+ queryKey: [
+ ...agentVaultKeys.variables(currentOrg.id),
+ "key-status-batch",
+ changeCount,
+ unchecked
+ ],
queryFn: async () => {
- const changeCount = variableChangeCounts.get(currentOrg.id) ?? 0;
const found = new Set<string>();
for (let i = 0; i < unchecked.length; i += KEY_LOOKUP_BATCH_SIZE) {
// eslint-disable-next-line no-await-in-loop