Skip to content

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

fix(pam): add isSecondaryInstance guard, fix base64 budget, expiration queue findById isolation, toast ref regression

bernie-g8d5fcde03cf7
diff --git a/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts b/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts
index 2c97436587..7e6923a90e 100644
--- a/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts
+++ b/backend/src/ee/services/pam-session/pam-session-ai-summary-queue.ts
@@ -1,5 +1,6 @@
import { TPamResourceDALFactory } from "@app/ee/services/pam-resource/pam-resource-dal";
import { PamResource } from "@app/ee/services/pam-resource/pam-resource-enums";
+import { getConfig } from "@app/lib/config/env";
import { logger } from "@app/lib/logger";
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
@@ -88,7 +89,13 @@ export const pamSessionAiSummaryServiceFactory = ({
await pamSessionDAL.updateById(sessionId, { aiInsightsStatus: "pending" });
};
+ const appCfg = getConfig();
+
const init = () => {
+ if (appCfg.isSecondaryInstance) {
+ return;
+ }
+
queueService.start(QueueName.PamSessionAiSummary, async (job) => {
const { sessionId, projectId } = job.data;
@@ -225,7 +232,8 @@ export const pamSessionAiSummaryServiceFactory = ({
for (const event of batchEvents) {
if (isSsh) {
const termEvent = event as TTerminalEvent;
- if (termEvent.eventType === "input") contentChars += termEvent.data?.length ?? 0;
+ if (termEvent.eventType === "input")
+ contentChars += termEvent.data ? Buffer.from(termEvent.data, "base64").length : 0;
} else {
const cmdLog = event as TPamSessionCommandLog;
contentChars += (cmdLog.input?.length ?? 0) + (cmdLog.output?.length ?? 0);
diff --git a/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts b/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
index 683cc09b2d..dcb941fff8 100644
--- a/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
+++ b/backend/src/services/pam-session-expiration/pam-session-expiration-queue.ts
@@ -29,7 +29,7 @@ export const pamSessionExpirationServiceFactory = ({
try {
logger.info({ sessionId }, `${QueueName.PamSessionExpiration}: expiring session [sessionId=${sessionId}]`);
const updated = await pamSessionDAL.expireSessionById(sessionId);
- const session = updated > 0 ? await pamSessionDAL.findById(sessionId) : null;
+ const session = updated > 0 ? await pamSessionDAL.findById(sessionId).catch(() => null) : null;
if (updated > 0) {
logger.info(
{ sessionId },
diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx
index 3c3bc924af..c3fea74399 100644
--- a/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx
+++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/CommandLogView.tsx
@@ -19,20 +19,24 @@ export const CommandLogView = ({ logs, scrollToLogIndex }: Props) => {
const [expandedLogTimestamps, setExpandedLogTimestamps] = useState<Set<string>>(new Set());
const [search, setSearch] = useState("");
const handledScrollIndexRef = useRef<number | undefined>(undefined);
+ const toastShownRef = useRef<number | undefined>(undefined);
useEffect(() => {
if (scrollToLogIndex == null) {
handledScrollIndexRef.current = undefined;
+ toastShownRef.current = undefined;
return;
}
if (scrollToLogIndex === handledScrollIndexRef.current) return;
const target = logs[scrollToLogIndex - 1];
if (!target) {
- handledScrollIndexRef.current = scrollToLogIndex;
- createNotification({
- type: "info",
- text: "Log entry not yet loaded. Load more logs to jump to this entry."
- });
+ if (toastShownRef.current !== scrollToLogIndex) {
+ toastShownRef.current = scrollToLogIndex;
+ createNotification({
+ type: "info",
+ text: "Log entry not yet loaded. Load more logs to jump to this entry."
+ });
+ }
return;
}
handledScrollIndexRef.current = scrollToLogIndex;