nextcloud / integration_openai

OpenAI integration in Nextcloud
GNU Affero General Public License v3.0
48 stars 9 forks source link

This app makes Nextcloud 27.1.x Apps page crash because name is null #64

Closed nicdex closed 5 months ago

nicdex commented 5 months ago

Which version of integration_openai are you using?

latest

Which version of Nextcloud are you using?

27.1.4

Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.

Chrome 119.0.6045.199

Describe the Bug

When I load the Apps page in Nextcloud, no apps are showing.

Expected Behavior

When I load the Apps pages in Nextcloud, my apps are showing

To Reproduce

Loading the Apps page on Nextcloud 27.1.4

nicdex commented 5 months ago

Here's more details

This query https://nextcloud.eventsourcing.com/settings/apps/list returns

...partial json...

{
    "apps": [
        {
            "id": "integration_openai",
            "name": null,
            "description": null,
            "summary": null,
            "license": [
                "agpl"
            ],
            "author": "Julien Veyssier",
            "shipped": false,
            "version": "",
            "default_enable": "",

As you can see name field is null

In the Chrome console I see

TypeError: Cannot read properties of null (reading 'toLowerCase')
    at AppList.vue:135:1
    at Array.filter (<anonymous>)
    at o.apps (AppList.vue:135:1)
    at e.get (vue.runtime.esm.js:3446:33)
    at e.evaluate (vue.runtime.esm.js:3547:27)
    at o.apps (vue.runtime.esm.js:5537:25)
    at o.hasPendingUpdate (AppList.vue:128:1)
    at e.get (vue.runtime.esm.js:3446:33)
    at e.evaluate (vue.runtime.esm.js:3547:27)
    at o.hasPendingUpdate (vue.runtime.esm.js:5537:25)

Code at AppList.vue:133-140

apps() {
    const apps = this.$store.getters.getAllApps
        .filter(app => app.name.toLowerCase().search(this.search.toLowerCase()) !== -1)
        .sort(function(a, b) {
            const sortStringA = '' + (a.active ? 0 : 1) + (a.update ? 0 : 1) + a.name
            const sortStringB = '' + (b.active ? 0 : 1) + (b.update ? 0 : 1) + b.name
            return OC.Util.naturalSortCompare(sortStringA, sortStringB)
        })

In resume, null name stops the list of Apps from displaying

MB-Finski commented 5 months ago

Hmm.. Thus far I'm unable to reproduce this on either 27.1.4 or master.

EDIT: ... and thanks for the bug report!

MB-Finski commented 5 months ago

This started happening with the v1.1.3 release?

MB-Finski commented 5 months ago

Finally, was able to reproduce this: this happens if you don't have the app installed.

hudecof commented 5 months ago

Hello,

this all is causing the Application list to be empty, There are missing some propertis, see the application error log The line could be +/- 1 since I was debuging the code.

{"reqId":"APqRwMDZcb55uw8QbHJY","level":3,"time":"2023-12-05T15:23:27+00:00","remoteAddr":"::ffff:80.211.216.27","user":"peter@home.hudecof.net","app":"PHP","method":"GET","url":"/index.php/settings/apps/list","message":"Trying to access array offset on value of type null at /srv/cloud/htdocs/apps/settings/lib/Controller/AppSettingsController.php#374","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","version":"27.1.4.1","data":{"app":"PHP"}}
{"reqId":"APqRwMDZcb55uw8QbHJY","level":3,"time":"2023-12-05T15:23:27+00:00","remoteAddr":"::ffff:80.211.216.27","user":"peter@home.hudecof.net","app":"PHP","method":"GET","url":"/index.php/settings/apps/list","message":"Undefined array key \"en\" at /srv/cloud/htdocs/apps/settings/lib/Controller/AppSettingsController.php#375","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36","version":"27.1.4.1","data":{"app":"PHP"}}
MB-Finski commented 5 months ago

Seems like the app store is unable to parse the app info.xml. We're looking into this.

akomm commented 5 months ago

So If I get it correct its not something messed up in the instances itself, its a remote list fetching issue?

hudecof commented 5 months ago

@akomm I do not have OpenAI installted at all. I was debugging the code and the erroer lines was right after this openai plugin. So yes, it seems to be not in the instance itself. @MB-Finski seems to be right.

MB-Finski commented 5 months ago

Temporarily fixed in https://github.com/nextcloud/integration_openai/releases/tag/v1.1.4

Here's what we know so far:

The issue stemmed from an erroneous response from https://apps.nextcloud.com/api/v1/apps.json The response did not contain the name, description or summary for integration_openai under the translations key. We figured that the error might be related to some syntax errors in the translations so to provide a quick fix all relevant translations were removed. We then pushed a new release to app store which seems to have fixed the issue. The apps.json response is cached by the server for a short time so you may still experience this issue but it'll resolve itself.

akomm commented 5 months ago

The app page works now (probably after fix). Before fix the list I received checking the network was ALL apps had no name.

MB-Finski commented 5 months ago

There was no obvious reason or trace in the logs on what exactly went wrong with the v1.1.3 update. Therefore, we let transifex bot re-sync the translations and published a new version of the app (v1.1.5). For whatever reason the issue did not reappear. We'll continue researching the issue but for now it seems that there were no issues with the v1.1.3 integration_openai itself.

bigcat88 commented 5 months ago

My observations (not necessarily true):

  1. The problem was not in the translations, just for some reason, when uploading the release to the app store, new data was not uploaded to the fields: name, summary, description.
  2. No errors were found in the database logs.
  3. Errors in the app store logs clearly indicating why the entry to these fields did not occur either.
  4. The code that is responsible for this was written a long time ago and has not changed; in a couple of hours I did not find any errors in it.

My conclusion: some kind of memory error occurred, which happens once in a million cases, or some kind of race-condition, that is not related to this project(integration_openai).

I suggest we close this issue and move it to the appstore repo, if in future something like this will happen we know where to find this topic.