n8n-nodes-github-copilot 1.1.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ class GitHubApi {
30
30
  displayName: 'Scope',
31
31
  name: 'scope',
32
32
  type: 'hidden',
33
- default: 'copilot read:org repo user',
33
+ default: 'admin:public_key gist read:org repo',
34
34
  },
35
35
  {
36
36
  displayName: 'Auth URI Query Parameters',
@@ -324,18 +324,74 @@ class GitHubCopilot {
324
324
  stderr = err.stderr || err.message || String(execError);
325
325
  stdout = err.stdout || '';
326
326
  }
327
+ async function checkTokenPermissions(token) {
328
+ try {
329
+ const authCheckCommand = `/usr/bin/gh auth status`;
330
+ const apiCheckCommand = `/usr/bin/gh api user`;
331
+ const envVarsCheck = {
332
+ ...process.env,
333
+ HOME: '/opt/n8n-source/packages/cli/bin',
334
+ GH_TOKEN: token,
335
+ GITHUB_TOKEN: token,
336
+ };
337
+ let permissionInfo = '';
338
+ try {
339
+ const authResult = await execAsync(authCheckCommand, { env: envVarsCheck, timeout: 10000 });
340
+ permissionInfo += `Auth Status: ${authResult.stdout.trim()}\n`;
341
+ }
342
+ catch (authError) {
343
+ const err = authError;
344
+ permissionInfo += `Auth Status Error: ${err.stderr || err.message}\n`;
345
+ }
346
+ try {
347
+ const apiResult = await execAsync(apiCheckCommand, { env: envVarsCheck, timeout: 10000 });
348
+ const userInfo = JSON.parse(apiResult.stdout);
349
+ permissionInfo += `User: ${userInfo.login} (${userInfo.name || 'no name'})\n`;
350
+ }
351
+ catch (apiError) {
352
+ const err = apiError;
353
+ permissionInfo += `API Access Error: ${err.stderr || err.message}\n`;
354
+ }
355
+ try {
356
+ await execAsync(`/usr/bin/gh api -H "Accept: application/vnd.github+json" /user`, { env: envVarsCheck, timeout: 10000 });
357
+ permissionInfo += `API Test: Success\n`;
358
+ }
359
+ catch (scopesError) {
360
+ const err = scopesError;
361
+ permissionInfo += `API Test Error: ${err.stderr || err.message}\n`;
362
+ }
363
+ return permissionInfo;
364
+ }
365
+ catch (error) {
366
+ return `Permission check failed: ${error}`;
367
+ }
368
+ }
327
369
  if (stderr) {
328
- if (stderr.includes('internal server error') || stderr.includes('code: 400')) {
329
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot service is temporarily unavailable (HTTP 400). This is a GitHub server issue. Please try again in a few moments. Error: ${stderr}`);
370
+ let debugTokenInfo = '';
371
+ let permissionInfo = '';
372
+ if (authType !== 'manual') {
373
+ debugTokenInfo = authType === 'local'
374
+ ? ' [Local CLI - no token passed]'
375
+ : ` [Token used: ${accessToken || 'none'}]`;
376
+ if (authType === 'oauth2' && accessToken) {
377
+ permissionInfo = await checkTokenPermissions(accessToken);
378
+ debugTokenInfo += `\n\nToken Permissions Check:\n${permissionInfo}`;
379
+ }
380
+ }
381
+ if (stderr.includes('internal server error') || stderr.includes('code: 500')) {
382
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot service is temporarily unavailable (HTTP 500). This is a GitHub server issue. Please try again in a few moments.${debugTokenInfo} Error: ${stderr}`);
383
+ }
384
+ else if (stderr.includes('code: 400') || stderr.includes('Bad Request')) {
385
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot request failed (HTTP 400). The request is malformed or invalid.${debugTokenInfo} Full error response: ${stderr}`);
330
386
  }
331
387
  else if (stderr.includes('401') || stderr.includes('Unauthorized') || stderr.includes('Bad credentials')) {
332
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub authentication failed. Please check your token has Copilot permissions. Error: ${stderr}`);
388
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub authentication failed (HTTP 401). Please check your token has Copilot permissions.${debugTokenInfo} Full error response: ${stderr}`);
333
389
  }
334
390
  else if (stderr.includes('403') || stderr.includes('Forbidden')) {
335
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot access denied. Please ensure your account has Copilot subscription. Error: ${stderr}`);
391
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot access denied (HTTP 403). Please ensure your account has Copilot subscription.${debugTokenInfo} Full error response: ${stderr}`);
336
392
  }
337
393
  else if (!stdout) {
338
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error: ${stderr}`);
394
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `GitHub Copilot CLI error:${debugTokenInfo} Full error response: ${stderr}`);
339
395
  }
340
396
  }
341
397
  const filterOutput = this.getNodeParameter('filterOutput', i, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-github-copilot",
3
- "version": "1.1.6",
3
+ "version": "1.2.0",
4
4
  "description": "n8n community node for GitHub Copilot CLI integration",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/sufficit/n8n-nodes-github-copilot",