chore: add logging in auth (#616)

* chore: add logging in auth

* cr
This commit is contained in:
Brace Sproul 2025-07-30 16:52:43 -07:00 • committed by GitHub
parent ef44fe9aac
commit 20658ac4c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,9 @@ import { LANGGRAPH_USER_PERMISSIONS } from "../constants.js";
import { getGitHubPatFromRequest } from "../utils/github-pat.js";
import { isAllowedUser } from "@open-swe/shared/github/allowed-users";
import { validate } from "uuid";
import { createLogger, LogLevel } from "../utils/logger.js";
const logger = createLogger(LogLevel.INFO, "Auth");
// TODO: Export from LangGraph SDK
export interface BaseAuthReturn {
@ -38,6 +41,7 @@ interface AuthenticateReturn extends BaseAuthReturn {
function apiKeysInRequestBody(
bodyStr: string | Record<string, unknown>,
): boolean {
logger.info("CHECKING RUN REQ BODY!!", bodyStr);
try {
const body = typeof bodyStr === "string" ? JSON.parse(bodyStr) : bodyStr;
if (
@ -46,11 +50,16 @@ function apiKeysInRequestBody(
"openaiApiKey" in body.config.configurable.apiKeys ||
"googleApiKey" in body.config.configurable.apiKeys)
) {
logger.info("RUN REQ BODY CONTAINS API KEYS!!", bodyStr);
return true;
}
logger.info("RUN REQ BODY DOES NOT CONTAIN API KEYS!!", bodyStr);
return false;
} catch {
// no-op
} catch (e: any) {
logger.error("RUN REQ BODY DOES NOT CONTAIN API KEYS!!", {
bodyStr,
error: e,
});
return false;
}
}