coderabbit suggestions

This commit is contained in:
msukkari 2025-10-21 19:06:54 -07:00
parent 1cd90071b3
commit 4af3b53062
8 changed files with 35 additions and 179 deletions

View file

@ -63,8 +63,8 @@ The following environment variables allow you to configure your Sourcebot deploy
| Variable | Default | Description | | Variable | Default | Description |
| :------- | :------ | :---------- | | :------- | :------ | :---------- |
| `GITHUB_REVIEW_AGENT_APP_ID` | `-` | <p>The GitHub App ID used for review agent authentication.</p> | | `GITHUB_REVIEW_AGENT_APP_ID` | `-` | <p>The GitHub App ID used for review agent authentication.</p> |
| `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET` | `-` | <p>The container relative path to the private key file for the GitHub App used by the review agent.</p> | | `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH` | `-` | <p>The container relative path to the private key file for the GitHub App used by the review agent.</p> |
| `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH` | `-` | <p>The webhook secret for the GitHub App used by the review agent.</p> | | `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET` | `-` | <p>The webhook secret for the GitHub App used by the review agent.</p> |
| `OPENAI_API_KEY` | `-` | <p>The OpenAI API key used by the review agent.</p> | | `OPENAI_API_KEY` | `-` | <p>The OpenAI API key used by the review agent.</p> |
| `REVIEW_AGENT_API_KEY` | `-` | <p>The Sourcebot API key used by the review agent.</p> | | `REVIEW_AGENT_API_KEY` | `-` | <p>The Sourcebot API key used by the review agent.</p> |
| `REVIEW_AGENT_AUTO_REVIEW_ENABLED` | `false` | <p>Enables/disables automatic code reviews by the review agent.</p> | | `REVIEW_AGENT_AUTO_REVIEW_ENABLED` | `false` | <p>Enables/disables automatic code reviews by the review agent.</p> |

View file

@ -15,14 +15,13 @@
}, },
"deploymentHostname": { "deploymentHostname": {
"type": "string", "type": "string",
"format": "url", "format": "hostname",
"default": "github.com", "default": "github.com",
"description": "The hostname of the GitHub App deployment.", "description": "The hostname of the GitHub App deployment.",
"examples": [ "examples": [
"github.com", "github.com",
"github.example.com" "github.example.com"
], ]
"pattern": "^[^\\s/$.?#].[^\\s]*$"
}, },
"id": { "id": {
"type": "string", "type": "string",
@ -58,37 +57,6 @@
"additionalProperties": false "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": [ "required": [

View file

@ -11,14 +11,13 @@
}, },
"deploymentHostname": { "deploymentHostname": {
"type": "string", "type": "string",
"format": "url", "format": "hostname",
"default": "github.com", "default": "github.com",
"description": "The hostname of the GitHub App deployment.", "description": "The hostname of the GitHub App deployment.",
"examples": [ "examples": [
"github.com", "github.com",
"github.example.com" "github.example.com"
], ]
"pattern": "^[^\\s/$.?#].[^\\s]*$"
}, },
"id": { "id": {
"type": "string", "type": "string",
@ -54,37 +53,6 @@
"additionalProperties": false "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": [ "required": [

View file

@ -71,25 +71,30 @@ export class GithubAppManager {
logger.info(`Found ${installations.data.length} GitHub App installations for ${deploymentHostname}/${app.id}:`); logger.info(`Found ${installations.data.length} GitHub App installations for ${deploymentHostname}/${app.id}:`);
for (const installationData of installations.data) { 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;
}
const owner = installationData.account?.login!; logger.info(`\tInstallation ID: ${installationData.id}, Account: ${installationData.account.login}, Type: ${installationData.account.type}`);
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 = { const owner = installationData.account.login;
id: installationData.id, const accountType = installationData.account.type.toLowerCase() as 'organization' | 'user';
appId: Number(app.id), const installationOctokit = await octokitApp.getInstallationOctokit(installationData.id);
account: { const auth = await installationOctokit.auth({ type: "installation" }) as { expires_at: string, token: string };
login: owner,
type: accountType, const installation: Installation = {
}, id: installationData.id,
createdAt: installationData.created_at, appId: Number(app.id),
expiresAt: auth.expires_at, account: {
token: auth.token login: owner,
}; type: accountType,
this.installationMap.set(this.generateMapKey(owner, deploymentHostname), installation); },
createdAt: installationData.created_at,
expiresAt: auth.expires_at,
token: auth.token
};
this.installationMap.set(this.generateMapKey(owner, deploymentHostname), installation);
} }
} }

View file

@ -14,14 +14,13 @@ const schema = {
}, },
"deploymentHostname": { "deploymentHostname": {
"type": "string", "type": "string",
"format": "url", "format": "hostname",
"default": "github.com", "default": "github.com",
"description": "The hostname of the GitHub App deployment.", "description": "The hostname of the GitHub App deployment.",
"examples": [ "examples": [
"github.com", "github.com",
"github.example.com" "github.example.com"
], ]
"pattern": "^[^\\s/$.?#].[^\\s]*$"
}, },
"id": { "id": {
"type": "string", "type": "string",
@ -57,37 +56,6 @@ const schema = {
"additionalProperties": false "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": [ "required": [

View file

@ -10,14 +10,13 @@ const schema = {
}, },
"deploymentHostname": { "deploymentHostname": {
"type": "string", "type": "string",
"format": "url", "format": "hostname",
"default": "github.com", "default": "github.com",
"description": "The hostname of the GitHub App deployment.", "description": "The hostname of the GitHub App deployment.",
"examples": [ "examples": [
"github.com", "github.com",
"github.example.com" "github.example.com"
], ]
"pattern": "^[^\\s/$.?#].[^\\s]*$"
}, },
"id": { "id": {
"type": "string", "type": "string",
@ -53,37 +52,6 @@ const schema = {
"additionalProperties": false "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": [ "required": [

View file

@ -29,22 +29,6 @@ export type GithubAppConfig = {
*/ */
env: string; 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; [k: string]: unknown;
}; };

View file

@ -9,14 +9,13 @@
}, },
"deploymentHostname": { "deploymentHostname": {
"type": "string", "type": "string",
"format": "url", "format": "hostname",
"default": "github.com", "default": "github.com",
"description": "The hostname of the GitHub App deployment.", "description": "The hostname of the GitHub App deployment.",
"examples": [ "examples": [
"github.com", "github.com",
"github.example.com" "github.example.com"
], ]
"pattern": "^[^\\s/$.?#].[^\\s]*$"
}, },
"id": { "id": {
"type": "string", "type": "string",
@ -25,10 +24,6 @@
"privateKey": { "privateKey": {
"$ref": "./shared.json#/definitions/Token", "$ref": "./shared.json#/definitions/Token",
"description": "The private key of the GitHub App." "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": [ "required": [