diff --git a/apps/open-swe/src/utils/github-tokens.ts b/apps/open-swe/src/utils/github-tokens.ts index a0ac7ca0..8798ae8a 100644 --- a/apps/open-swe/src/utils/github-tokens.ts +++ b/apps/open-swe/src/utils/github-tokens.ts @@ -24,23 +24,24 @@ export function getGitHubTokensFromConfig(config: GraphConfig): { const isProd = process.env.NODE_ENV === "production"; - const installationId = config.configurable[GITHUB_INSTALLATION_ID]; - if (!installationId) { - throw new Error( - `Missing required ${GITHUB_INSTALLATION_ID} in configuration.`, - ); - } - const githubPat = getGitHubPatFromConfig(config.configurable, encryptionKey); if (githubPat && !isProd) { // check for PAT-only mode return { githubAccessToken: githubPat, githubInstallationToken: githubPat, - installationId, + // installationId is not required in PAT-only mode + installationId: config.configurable[GITHUB_INSTALLATION_ID] ?? "", }; } + const installationId = config.configurable[GITHUB_INSTALLATION_ID]; + if (!installationId) { + throw new Error( + `Missing required ${GITHUB_INSTALLATION_ID} in configuration.`, + ); + } + const encryptedGitHubToken = config.configurable[GITHUB_TOKEN_COOKIE]; const encryptedInstallationToken = config.configurable[GITHUB_INSTALLATION_TOKEN_COOKIE];