chatgpt-google-summary-extension icon indicating copy to clipboard operation
chatgpt-google-summary-extension copied to clipboard

Errors when loading the self-built package to chrome

Open h4n0 opened this issue 1 year ago • 3 comments

Describe the bug I cloned the latest main branch and built it locally following the instructions. Chrome shows errors when I load the package. The error messages are:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'config')
Context
options.html
Stack Trace
options.js:203 (anonymous function)
Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'apiKey')
Context
https://github.com/sparticleinc/chatgpt-google-summary-extension/issues/new/choose
Stack Trace
content-script.js:6 (anonymous function)

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • Version: https://github.com/sparticleinc/chatgpt-google-summary-extension/tree/2fe8cdeed80ef816bd53074ef17dd23cde25d22a

h4n0 avatar Apr 16 '24 14:04 h4n0

I got the same problem

folkevil avatar May 02 '24 03:05 folkevil

Was able to resolve this by modifying src/options/ProviderSelect.tsx

function ProviderSelect() {
  ...

  if (query.isLoading) {
    return <Spinner />
  }

  // Added this
  if (query.error) {
    return <div>Error loading provider configurations.</div>
  }

  // Don't think you need this but added it to be safe
  if (!query.data || !query.data.config) {
    return <div>No provider configurations found.</div>
  }

  return <ConfigPanel config={query.data!.config} models={models} />
}

as well as src/config/index.ts

export async function getProviderConfigs(): Promise<ProviderConfigs> {
  ...

  // Ensure result[configKey] is not undefined
  if (!result[configKey]) {
    result[configKey] = {}
  }
  result[configKey].apiKey = apiKey

  return {
    provider,
    configs: {
      [ProviderType.GPT3]: result[configKey],
    },
  }
}

dillontkh avatar May 17 '24 08:05 dillontkh

Thanks @dillontkh It has worked for me. Made a PR

in-c0 avatar Sep 20 '24 20:09 in-c0