Passwords: Expected application/json, got text/html

Hi The most common message in the log is like this:

/appinfo/app.php is not loaded when \OCP\AppFramework\Bootstrap\IBootstrap on the application class is used. Migrate everything from app.php to the Application class.

Unfortunately this is set as an error level, so disabling the info and debug did not help much. Is there any way to get rid of the message above, or at least filter it out? It creates a lot of useless logdata and probably some strain to the machine too.

Best regards Stefan

Hmm. I checked some of these apps and they shouldn’t have an app.php, e.g. “Polls”, “viewer” and “files_versions” (which is a core app).

If you update the apps and Nextcloud itself this way, do you also delete the old code first? Otherwise you’re basically running a NC remix with lots of different code mixed together.

I have a lot of app.php files in the nextcloud directory. What to do about it?

locate app.php

/home/httpd/htdocs/nextcloud/apps/activity/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/admin_audit/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/cloud_federation_api/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/comments/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/contactsinteraction/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/dav/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/encryption/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/federatedfilesharing/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/federation/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/files/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/files_external/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/files_pdfviewer/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/files_rightclick/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/files_sharing/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/files_trashbin/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/files_versions/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/firstrunwizard/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/hsts/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/logreader/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/lookup_server_connector/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/nextcloud_announcements/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/notifications/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/password_policy/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/passwords/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/photos/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/recommendations/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/serverinfo/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/sharebymail/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/support/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/survey_client/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/systemtags/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/text/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/theming/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/twofactor_backupcodes/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/updatenotification/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/user_ldap/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/viewer/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps/workflowengine/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/accessibility/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/activity/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/admin_audit/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/cloud_federation_api/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/comments/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/contactsinteraction/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/dav/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/encryption/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/federatedfilesharing/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/federation/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files_external/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files_pdfviewer/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files_rightclick/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files_sharing/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files_trashbin/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files_versions/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/files_videoplayer/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/firstrunwizard/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/logreader/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/lookup_server_connector/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/nextcloud_announcements/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/notifications/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/password_policy/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/photos/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/recommendations/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/serverinfo/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/sharebymail/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/support/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/survey_client/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/systemtags/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/text/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/theming/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/twofactor_backupcodes/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/updatenotification/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/user_ldap/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/viewer/appinfo/app.php
/home/httpd/htdocs/nextcloud/apps-pkg/workflowengine/appinfo/app.php

So pretty much all of these i checked don’t have an app.php anymore, including the passwords app.

I don’t think Nextcloud is still loading the app.php, but that may not be the case of any other old code that you still have laying around. Having old code around is bad because NC or apps may run that code and end up in an unexpected state.

Additionally, it seems like many apps are in both apps and apps-pkg. I can’t tell you which one of these Nexcloud is loading, that depends on the configuration.

I’m not sure how to best solve this situation, maybe it’s worth to ask in :information_source: Support.

My strategy would be to follow the manual upgrade guide and perform an “upgrade” to the same version. But in step 9 & 10, instead of copying your custom apps over, download the latest version and install that into the upgraded instance.

In any case, make a backup first.

Hi

I made a reinstallation of nextcloud and got rid of most errors above. The errors conecering passwords are as follows:

Fatal passwords OCA\Passwords\Exception\ApiException: Internal Favicon API Error
2023-12-11T10:58:28+0100

Error passwords Error “Internal Favicon API Error” in OCA\Passwords\Controller\Api\ServiceApiController::getFavicon
2023-12-11T10:58:28+0100

Fatal passwords ImagickException: attempt to perform an operation not allowed by the security policy `MVG’ @ error/constitute.c/IsCoderAuthorized/449
2023-12-11T10:58:28+0100

Fatal passwords ImagickException: attempt to perform an operation not allowed by the security policy `MVG’ @ error/constitute.c/IsCoderAuthorized/449
2023-12-11T10:58:28+0100

Fatal passwords OCA\Passwords\Exception\ApiException: Internal Favicon API Error
2023-12-11T10:58:28+0100

Error passwords Error “Internal Favicon API Error” in OCA\Passwords\Controller\Api\ServiceApiController::getFavicon
2023-12-11T10:58:28+0100

Fatal passwords ImagickException: attempt to perform an operation not allowed by the security policy `MVG’ @ error/constitute.c/IsCoderAuthorized/449
2023-12-11T10:58:28+0100

Fatal passwords ImagickException: attempt to perform an operation not allowed by the security policy `MVG’ @ error/constitute.c/IsCoderAuthorized/449

Thos are just errors from the favicon api where your systems ImageMagick is set up in a way that doesn’t allow it to process some types of images, in this case MVG. That’s not really much of an issue and you can fix it either by changing the ImageMagick policies or switching to another image processing method in the passwords app settings.

Can you try and see what happens now if you try to connect the extension?

Hi se error messages below:


After removing ImageMagick inte the settings. This is the only error message:

Iwill recompile PHP with IPv6 (I am not using IPV6).

I’m not sure if that’s the error that causes the issue, because it happened when you opened the app in nextcloud.

but a similar call happens in the request that fails and causes the 404.

The easy way to go around that would be to just install the handbook extension: https://apps.nextcloud.com/apps/passwords_handbook

Alternatively you can also try php ./occ config:system:set allow_local_remote_servers --value=true --type=bool; but i don’t know if that stops NC from checking that

PHP upgraded to 8.1.26 with IPv6 enabled. The same error message is still shown when using passlink but theres no messages in the log at any level. :frowning:
I also ran the command in your last message but nothing changed.

System config value allow_local_remote_servers set to boolean true

After the upgrade I get a new warning in the admin “Security and systemwarnings”

Your server is not configured correctly to resolve “/nextcloud/ocm-provider/”

Well that sucks. The only thing i can suggest now is debugging why the endpoint doesn’t work.

In the file lib/Controller/Api/SessionApiController.php in the apps/passwords folder, there is the function “request” around line 101.

Can you modify it like this to comment out the token check?

    public function request(): JSONResponse {
        if(!$this->loginAttempts->isAttemptAllowed()) {
            throw new ApiException('Login not allowed', Http::STATUS_FORBIDDEN);
        }

        $requirements = new stdClass();
        if(!$this->session->isAuthorized()) {
            if($this->challengeService->hasChallenge()) {
                $requirements->challenge = $this->challengeService->getChallengeData();

//                if($this->tokenHelper->hasToken() && $this->das->check('two-factor-enabled', true)) {
//                    $requirements->token = $this->tokenHelper->getProvidersAsArray();
//                }
            }
        }

        return new JSONResponse($requirements);
    }

If it still doesn’t work, try commenting out the whole authorization check:

    public function request(): JSONResponse {
        if(!$this->loginAttempts->isAttemptAllowed()) {
            throw new ApiException('Login not allowed', Http::STATUS_FORBIDDEN);
        }

        $requirements = new stdClass();
//        if(!$this->session->isAuthorized()) {
//            if($this->challengeService->hasChallenge()) {
//                $requirements->challenge = $this->challengeService->getChallengeData();
//
//                if($this->tokenHelper->hasToken() && $this->das->check('two-factor-enabled', true)) {
//                    $requirements->token = $this->tokenHelper->getProvidersAsArray();
//                }
//            }
//        }

        return new JSONResponse($requirements);
    }

Something there has to cause the 404 error, but just from looking at it i can’t see what.

Two more things: Can you open the developer tools in Firefox, then open the app in Nextcloud and see if there are any 404s in the requests in the Network tab there?

With the code removed as in your second example above there was a slight change:

charset=UTF-8

Can you check again what the http status code of that request was?

Hi How do I do that?

Another error is turning up in the log now when I try to connect i Passwords:

Can you check the code again. I think somewhere is a lonely “}”

Ok I restored the code from passwords.tar.gz and this error disappered. Now theres a new error in the log:

Maybe I should restore yesterdays backup?

That error should be no issue. It can happen when the passlink connect process times out.

So this is the code I have commented out in SessionApiController.php:

// if(!$this->session->isAuthorized()) {
// if($this->challengeService->hasChallenge()) {
// $requirements->challenge = $this->challengeService->getChallengeData();
//
// if($this->tokenHelper->hasToken() && $this->das->check(‘two-factor-enabled’, true)) {
// $requirements->token = $this->tokenHelper->getProvidersAsArray();
// }
// }
// }

Any more ideas how to continue debugging?

So it’s still not working even if all relevant code is commented out? I’m confused.

What happens if you just write

    public function request(): JSONResponse {
        return new JSONResponse((object) []);
    }

as the function?

I’m really confused because there is nothing in there that isn’t also done when you use the webapp. It’s like something is blocking selectively the only endpoint that the webapp skips.

Now it (very briefly) prints 404 in a small popup when I click “Connect with Passlink” under Passwords → More → Applications and Addons.