diff --git a/docs/docs/configuration/environment-variables.mdx b/docs/docs/configuration/environment-variables.mdx index 953d5521..b6fba9eb 100644 --- a/docs/docs/configuration/environment-variables.mdx +++ b/docs/docs/configuration/environment-variables.mdx @@ -63,8 +63,8 @@ The following environment variables allow you to configure your Sourcebot deploy | Variable | Default | Description | | :------- | :------ | :---------- | | `GITHUB_REVIEW_AGENT_APP_ID` | `-` |

The GitHub App ID used for review agent authentication.

| -| `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET` | `-` |

The container relative path to the private key file for the GitHub App used by the review agent.

| -| `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH` | `-` |

The webhook secret for the GitHub App used by the review agent.

| +| `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH` | `-` |

The container relative path to the private key file for the GitHub App used by the review agent.

| +| `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET` | `-` |

The webhook secret for the GitHub App used by the review agent.

| | `OPENAI_API_KEY` | `-` |

The OpenAI API key used by the review agent.

| | `REVIEW_AGENT_API_KEY` | `-` |

The Sourcebot API key used by the review agent.

| | `REVIEW_AGENT_AUTO_REVIEW_ENABLED` | `false` |

Enables/disables automatic code reviews by the review agent.

| diff --git a/docs/snippets/schemas/v3/app.schema.mdx b/docs/snippets/schemas/v3/app.schema.mdx index 391ac210..7eabc79f 100644 --- a/docs/snippets/schemas/v3/app.schema.mdx +++ b/docs/snippets/schemas/v3/app.schema.mdx @@ -15,14 +15,13 @@ }, "deploymentHostname": { "type": "string", - "format": "url", + "format": "hostname", "default": "github.com", "description": "The hostname of the GitHub App deployment.", "examples": [ "github.com", "github.example.com" - ], - "pattern": "^[^\\s/$.?#].[^\\s]*$" + ] }, "id": { "type": "string", @@ -58,37 +57,6 @@ "additionalProperties": false } ] - }, - "privateKeyPath": { - "description": "The path to the private key of the GitHub App.", - "anyOf": [ - { - "type": "object", - "properties": { - "secret": { - "type": "string", - "description": "The name of the secret that contains the token." - } - }, - "required": [ - "secret" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "env": { - "type": "string", - "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." - } - }, - "required": [ - "env" - ], - "additionalProperties": false - } - ] } }, "required": [ diff --git a/docs/snippets/schemas/v3/githubApp.schema.mdx b/docs/snippets/schemas/v3/githubApp.schema.mdx index 4ad5eb4c..2d1aea88 100644 --- a/docs/snippets/schemas/v3/githubApp.schema.mdx +++ b/docs/snippets/schemas/v3/githubApp.schema.mdx @@ -11,14 +11,13 @@ }, "deploymentHostname": { "type": "string", - "format": "url", + "format": "hostname", "default": "github.com", "description": "The hostname of the GitHub App deployment.", "examples": [ "github.com", "github.example.com" - ], - "pattern": "^[^\\s/$.?#].[^\\s]*$" + ] }, "id": { "type": "string", @@ -54,37 +53,6 @@ "additionalProperties": false } ] - }, - "privateKeyPath": { - "description": "The path to the private key of the GitHub App.", - "anyOf": [ - { - "type": "object", - "properties": { - "secret": { - "type": "string", - "description": "The name of the secret that contains the token." - } - }, - "required": [ - "secret" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "env": { - "type": "string", - "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." - } - }, - "required": [ - "env" - ], - "additionalProperties": false - } - ] } }, "required": [ diff --git a/packages/backend/src/ee/githubAppManager.ts b/packages/backend/src/ee/githubAppManager.ts index 71755a55..2205b939 100644 --- a/packages/backend/src/ee/githubAppManager.ts +++ b/packages/backend/src/ee/githubAppManager.ts @@ -71,25 +71,30 @@ export class GithubAppManager { logger.info(`Found ${installations.data.length} GitHub App installations for ${deploymentHostname}/${app.id}:`); for (const installationData of installations.data) { - logger.info(`\tInstallation ID: ${installationData.id}, Account: ${installationData.account?.login}, Type: ${installationData.account?.type}`); + if (!installationData.account || !installationData.account.login || !installationData.account.type) { + logger.warn(`Skipping installation ${installationData.id}: missing account data (${installationData.account})`); + continue; + } + + logger.info(`\tInstallation ID: ${installationData.id}, Account: ${installationData.account.login}, Type: ${installationData.account.type}`); - const owner = installationData.account?.login!; - const accountType = installationData.account?.type!.toLowerCase() as 'organization' | 'user'; - const installationOctokit = await octokitApp.getInstallationOctokit(installationData.id); - const auth = await installationOctokit.auth({ type: "installation" }) as { expires_at: string, token: string }; - - const installation: Installation = { - id: installationData.id, - appId: Number(app.id), - account: { - login: owner, - type: accountType, - }, - createdAt: installationData.created_at, - expiresAt: auth.expires_at, - token: auth.token - }; - this.installationMap.set(this.generateMapKey(owner, deploymentHostname), installation); + const owner = installationData.account.login; + const accountType = installationData.account.type.toLowerCase() as 'organization' | 'user'; + const installationOctokit = await octokitApp.getInstallationOctokit(installationData.id); + const auth = await installationOctokit.auth({ type: "installation" }) as { expires_at: string, token: string }; + + const installation: Installation = { + id: installationData.id, + appId: Number(app.id), + account: { + login: owner, + type: accountType, + }, + createdAt: installationData.created_at, + expiresAt: auth.expires_at, + token: auth.token + }; + this.installationMap.set(this.generateMapKey(owner, deploymentHostname), installation); } } diff --git a/packages/schemas/src/v3/app.schema.ts b/packages/schemas/src/v3/app.schema.ts index d5a7dfee..5b4b96f7 100644 --- a/packages/schemas/src/v3/app.schema.ts +++ b/packages/schemas/src/v3/app.schema.ts @@ -14,14 +14,13 @@ const schema = { }, "deploymentHostname": { "type": "string", - "format": "url", + "format": "hostname", "default": "github.com", "description": "The hostname of the GitHub App deployment.", "examples": [ "github.com", "github.example.com" - ], - "pattern": "^[^\\s/$.?#].[^\\s]*$" + ] }, "id": { "type": "string", @@ -57,37 +56,6 @@ const schema = { "additionalProperties": false } ] - }, - "privateKeyPath": { - "description": "The path to the private key of the GitHub App.", - "anyOf": [ - { - "type": "object", - "properties": { - "secret": { - "type": "string", - "description": "The name of the secret that contains the token." - } - }, - "required": [ - "secret" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "env": { - "type": "string", - "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." - } - }, - "required": [ - "env" - ], - "additionalProperties": false - } - ] } }, "required": [ diff --git a/packages/schemas/src/v3/githubApp.schema.ts b/packages/schemas/src/v3/githubApp.schema.ts index 27d6445d..aab0ef20 100644 --- a/packages/schemas/src/v3/githubApp.schema.ts +++ b/packages/schemas/src/v3/githubApp.schema.ts @@ -10,14 +10,13 @@ const schema = { }, "deploymentHostname": { "type": "string", - "format": "url", + "format": "hostname", "default": "github.com", "description": "The hostname of the GitHub App deployment.", "examples": [ "github.com", "github.example.com" - ], - "pattern": "^[^\\s/$.?#].[^\\s]*$" + ] }, "id": { "type": "string", @@ -53,37 +52,6 @@ const schema = { "additionalProperties": false } ] - }, - "privateKeyPath": { - "description": "The path to the private key of the GitHub App.", - "anyOf": [ - { - "type": "object", - "properties": { - "secret": { - "type": "string", - "description": "The name of the secret that contains the token." - } - }, - "required": [ - "secret" - ], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "env": { - "type": "string", - "description": "The name of the environment variable that contains the token. Only supported in declarative connection configs." - } - }, - "required": [ - "env" - ], - "additionalProperties": false - } - ] } }, "required": [ diff --git a/packages/schemas/src/v3/githubApp.type.ts b/packages/schemas/src/v3/githubApp.type.ts index 7ed48a45..cd5af6af 100644 --- a/packages/schemas/src/v3/githubApp.type.ts +++ b/packages/schemas/src/v3/githubApp.type.ts @@ -29,22 +29,6 @@ export type GithubAppConfig = { */ env: string; }; - /** - * The path to the private key of the GitHub App. - */ - privateKeyPath?: - | { - /** - * The name of the secret that contains the token. - */ - secret: string; - } - | { - /** - * The name of the environment variable that contains the token. Only supported in declarative connection configs. - */ - env: string; - }; } & { [k: string]: unknown; }; diff --git a/schemas/v3/githubApp.json b/schemas/v3/githubApp.json index 43c0d600..c83553ce 100644 --- a/schemas/v3/githubApp.json +++ b/schemas/v3/githubApp.json @@ -9,14 +9,13 @@ }, "deploymentHostname": { "type": "string", - "format": "url", + "format": "hostname", "default": "github.com", "description": "The hostname of the GitHub App deployment.", "examples": [ "github.com", "github.example.com" - ], - "pattern": "^[^\\s/$.?#].[^\\s]*$" + ] }, "id": { "type": "string", @@ -25,10 +24,6 @@ "privateKey": { "$ref": "./shared.json#/definitions/Token", "description": "The private key of the GitHub App." - }, - "privateKeyPath": { - "$ref": "./shared.json#/definitions/Token", - "description": "The path to the private key of the GitHub App." } }, "required": [