Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Unknown provider' error when Sign in to use Github Copilot Chat extension #22781

Closed
RomanNikitenko opened this issue Jan 23, 2024 · 4 comments
Closed
Assignees
Labels
area/editor/vscode Issues related to the Code OSS editor of Che kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system. team/B This team is responsible for the Web Terminal, the DevWorkspace Operator and the IDEs.

Comments

@RomanNikitenko
Copy link
Member

RomanNikitenko commented Jan 23, 2024

Describe the bug

I was able to install the extension (see my screenshot below in the Additional context section), but I got the following error when Sign in to use Github Copilot Chat extension:

image

Che version

7.80@latest

Steps to reproduce

  1. Install Github Copilot Chat VS Code extension
  2. Click Sign In button
  3. The corresponding functionality doesn't work, see https://docs.github.com/en/copilot/github-copilot-chat/using-github-copilot-chat-in-your-ide
  4. See errors in browser console

Expected behavior

It's possible to Sign in and use Github Copilot Chat VS Code extension

Additional context

I reproduced it on the dogfooding instance

image
@RomanNikitenko RomanNikitenko added kind/bug Outline of a bug - must adhere to the bug report template. area/editor/vscode Issues related to the Code OSS editor of Che team/B This team is responsible for the Web Terminal, the DevWorkspace Operator and the IDEs. severity/P1 Has a major impact to usage or development of the system. labels Jan 23, 2024
@vitaliy-guliy
Copy link
Contributor

vitaliy-guliy commented Feb 21, 2024

@RomanNikitenko
Few questions:

  • How did you install the extension as it is not published to Open VSX?
  • Did you use a .vsix file?
  • With which extension version did you experiment?

@RomanNikitenko
Copy link
Member Author

@vitaliy-guliy

  • yes, I used vsix way to install the extension
  • you can see installed version on the screenshot: v0.12........

@vitaliy-guliy
Copy link
Contributor

Potentially depends on microsoft/vscode#205592

@vitaliy-guliy
Copy link
Contributor

vitaliy-guliy commented Mar 27, 2024

Workaround for workspaces without fixes in pull request

If you try to install the extensions in che-code from the main branch, the copilot chat extension will not work because it cannot get GitHub session due to specific call of the extension plugin API like here
https://github.com/vitaliy-guliy/vscode-test-extension/blob/get-session/src/extension.ts#L39

If silent is true, user will not be asked to permit giving the access to his account to the extension. And as result the extension will have undefined instead of a session.

If you apply this fixup, it will update your browser database and granted the access for Pull Request extension and for both Copilot extensions.

How to test:

  • on the dogfooding instance open the browser console, go to Application tab and remove all what you have in IndexedDB
  • create any workspace
  • copy the script below, open the browser console again, go to Console tab, paste the script, replace 'vitaliy-guliy' on your github login and execute the script
  • remove existing Device Authentication token and authorize again
  • reload the page
  • install pull request extension, copilot and copilot-chat extensions in exact sequence
  • everything should work now

Just to check this workaround is working, try to repeat above steps but do not launch the script.

(async function update() {
    try {
        const accountName = 'vitaliy-guliy';
        console.log(`> updating rules for ${accountName}`);

        const req = indexedDB.open('vscode-web-state-db-global');
        await new Promise((r) => (req.onsuccess = r));

        const transaction = req.result.transaction('ItemTable', "readwrite");
        const store = transaction.objectStore('ItemTable');

        const keys = store.getAllKeys();
        await new Promise((r) => (keys.onsuccess = r));

        let rules = [];
        let usages = [];

        if (keys.result.includes(`github-${accountName}`)) {
            const value = store.get(`github-${accountName}`);
            await new Promise((r) => (value.onsuccess = r));
            rules = JSON.parse(value.result);
        }

        if (keys.result.includes(`github-${accountName}-usages`)) {
            const value = store.get(`github-${accountName}-usages`);
            await new Promise((r) => (value.onsuccess = r));
            usages = JSON.parse(value.result);
        }

        const ensureRule = function (extensionId, name) {
            if (rules.find(rule => rule.id === extensionId)) {
                console.log(`> rule for ${extensionId} already exists`);
            } else {
                console.log(`> add rule for ${extensionId}`);
                rules.push({
                    "id": extensionId,
                    "name": name,
                    "allowed": true
                });
            }

            if (usages.find(usage => usage.extensionId === extensionId)) {
                console.log(`> usage for ${extensionId} already exists`);
            } else {
                console.log(`> add usage for ${extensionId}`);
                usages.push({
                    "extensionId": extensionId,
                    "extensionName": name,
                    "lastUsed": Date.now().toString()
                });
            }
        };

        ensureRule('github.copilot', 'GitHub Copilot');
        ensureRule('github.copilot-chat', 'GitHub Copilot Chat');

        const putRules = store.put(JSON.stringify(rules), `github-${accountName}`);
        await new Promise((r) => (putRules.onsuccess = r));

        const putUsages = store.put(JSON.stringify(usages), `github-${accountName}-usages`);
        await new Promise((r) => (putUsages.onsuccess = r));

        console.log('> done');

        await new Promise((r) => setTimeout(r, 1000));
        window.location.reload()
    } catch (e) {
        console.error(e, e.trace);
    }
})();

Check the vscode version you are using and download corresponding extensions

che-code@7.84.0 (main branch) / vscode@1.88.0 - dogfooding

che-code@7.82.1 / vscode@1.87.0 - staging with Dev Spaces 3.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/editor/vscode Issues related to the Code OSS editor of Che kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system. team/B This team is responsible for the Web Terminal, the DevWorkspace Operator and the IDEs.
Projects
None yet
Development

No branches or pull requests

2 participants