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

Try to linking a federated Circles throws an error #254

Open
johappel opened this issue Feb 13, 2019 · 6 comments
Open

Try to linking a federated Circles throws an error #254

johappel opened this issue Feb 13, 2019 · 6 comments

Comments

@johappel
Copy link

If I try to link between federatde Circles with NC 15.04 and Crcles App 0.16.0 on both servers I got the following Message from the Server.
Verknüpfung zu {remote} konnte nicht erstellt werden: Keine Fehlermeldung

Log File Error:
TypeError: Argument 1 passed to OCA\Circles\Db\FederatedLinksRequest::delete() must be an instance of OCA\Circles\Model\FederatedLink, null given, called in /home/me/public_html/apps/circles/lib/Service/FederatedLinkCreationService.php on line 243

Can anyone Help?

@chaptergy
Copy link

I probably have the same issue. The displayed message is

A link to {remote} could not be initiated: no error message

However unfortunately I don't have access to the log files, so I can't add any detailed information. Nc Version 15.0.7 and app version 0.16.5.

@wiswedel wiswedel changed the title Try to linking a federated Circles throws an arrow Try to linking a federated Circles throws an error Aug 23, 2019
@chaptergy
Copy link

chaptergy commented Aug 28, 2019

I have now retried with a different nextcloud instance, where I do have access to the lofs and here is the error with the full stack trace (obviously I have changed the id and uri of the circle used):

TypeError: Argument 1 passed to OCA\Circles\Db\FederatedLinksRequest::delete() must be an instance of OCA\Circles\Model\FederatedLink, null given, called in /var/www/nextcloud/apps/circles/lib/Service/FederatedLinkCreationService.php on line 243

    /var/www/nextcloud/apps/circles/lib/Service/FederatedLinkCreationService.php - line 243:
    OCA\Circles\Db\FederatedLinksRequest->delete(null)

    /var/www/nextcloud/apps/circles/lib/Service/FederatedLinkCreationService.php - line 151:
    OCA\Circles\Service\FederatedLinkCreationService->requestLinkWithRemoteCircle("18adc56019f80e", "test@redacted.com")

    /var/www/nextcloud/apps/circles/lib/Controller/LinksController.php - line 116:
    OCA\Circles\Service\FederatedLinkCreationService->createLinkWithRemoteCircle("18adc56019f80e", "test@redacted.com")

    /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 166:
    OCA\Circles\Controller\LinksController->createLink("18adc56019f80e", "test@redacted.com")

    /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 99:
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Circles\ ... {}, "createLink")

    /var/www/nextcloud/lib/private/AppFramework/App.php - line 118:
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Circles\ ... {}, "createLink")

    /var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47:
    OC\AppFramework\App::main("OCA\\Circle ... r", "createLink", OC\AppFramew ... {}, { uniqueId: ... "})

    <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({ uniqueId: ... "})

    /var/www/nextcloud/lib/private/Route/Router.php - line 297:
    call_user_func(OC\AppFramew ... {}, { uniqueId: ... "})

    /var/www/nextcloud/lib/base.php - line 987:
    OC\Route\Router->match("/apps/circl ... k")

    /var/www/nextcloud/index.php - line 42:
    OC::handleRequest()

The request doesn't even seem to reach the remote instance.
This issue could possibly be due to the nextcloud instance version being < 16? I have yet to test with two NC16 instances.

@chaptergy
Copy link

I have now confirmed that the issue still exists even with two nextcloud 16 instances. @daita

@chaptergy
Copy link

Okay, I have made some progress in figuring out this error.
First of all, the FederatedLinksRequest delete function did not accept null as an input parameter, so the error handling before failed. When adding the question mark to the type hinting, so it accepts null, we get more usable error messages.

So the next error was this:

{
    "circle_id": "d70e57xxxxb2c7",
    "remote": "test@redacted.com",
    "error": "An exception occurred while executing 'INSERT INTO \"oc_circles_links\" (\"creation\", \"status\", \"circle_id\", \"unique_id\", \"address\", \"token\") VALUES(?, ?, ?, ?, ?, ?)' with params [\"2019-10-14 09:09:04\", 2, \"d70e57xxxxb2c7\", \"\", \"redacted.com\", \"6f86c458de3440efc2xxxxxxxe7fb54fb53cf3cd14b49f6d\"]:\n\nSQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: oc_circles_links.key"
}

This is because database.xml defines a key field, which is not null, has no default and is not set during the insert process. I have no idea what this field is for, maybe @daita can help? But setting this to some fixed value seems to work for the time being.

Once this is fixed, a new error pops up:

{
    "circle_id": "d70e57xxxxb2c7",
    "remote": "test@redacted.com",
    "error": "Passing in the \"body\" request option as an array to send a POST request has been deprecated. Please use the \"form_params\" request option to send a application\/x-www-form-urlencoded request, or the \"multipart\" request option to send a multipart\/form-data request."
}

To fix this we will need to change the MiscService::generateClientBodyData(). But since this function is used elsewhere, we should just duplicate it and use the changed duplicate. Now a request is successfully sent! But we get an error on the receiving instance.
First this error is because a log() method is called with the parameters in the wrong order. With that fixed, there is a new error, when trying to accept the request:

{"link_id":"d70e57xxxxb2c7","error":"The status could not be updated"}

This error message leads to the FederatedLink Model.
It's the first check that throws the error. ($this->hasToBeValidStatusUpdateWhileLinkDown($status)). That means, the status is not self::STATUS_LINK_DOWN.
Then i commented that line out, which greets me with a new error message:

{
    "reqId": "XaRbc1KlVKMAAMYV2N4AAAAF",
    "level": 4,
    "time": "2019-10-14T11:26:43+00:00",
    "remoteAddr": "2003:cb:1747:b200:xxxx:xxxx:xxxx:1393",
    "user": "admin",
    "app": "circles",
    "method": "POST",
    "url": "/index.php/apps/circles/v1/link/d70e57xxxxb2c7/status",
    "message": "{\"link_id\":\"d70e57xxxxb2c7\",\"error\":\"Client error: `POST https:\\/\\/redacted.com\\/index.php\\/apps\\/circles\\/v1\\/link` resulted in a `404 Not Found` response:\\n<!DOCTYPE html>\\n<html>\\n  <head>\\n    <script src=\\\"https:\\/\\/ajax.googleapis.com\\/ajax\\/libs\\/jquery\\/2.1.3\\/jquery.min.js\\\"><\\/scr (truncated...)\\n\"}",
    "userAgent": "xxx",
    "version": "16.0.3.0",
    "id": "5da45b73c628a"
}

This is the point I've come to so far. If I find out more in the future, I will add more info. I've forked the repo and applied most of the changes mentioned above.

@chaptergy
Copy link

Okay, so after setting up two fresh instances, connecting the fedrated circles seems to work, however when actually sharing stuff it doesn't. Sharing a calendar just doesn't work at all, and when sharing files, new errors pop up.
In de UI a notification shows up saying:

Server error: `POST https://nc1.redacted.com/index.php/apps/circles/v1/payload` resulted in a `500 Internal Server Error` response

and in the error log this shows up, however I'm unsure of what caused this:

{
    "reqId": "XaSHZ1KlVKMAAJa1KwkAAAAb",
    "level": 3,
    "time": "2019-10-14T14:34:15+00:00",
    "remoteAddr": "82.xxx.xxx.xxx",
    "user": "--",
    "app": "PHP",
    "method": "POST",
    "url": "\/index.php\/apps\/circles\/v1\/payload",
    "message": "Trait 'daita\\MySmallPhpTools\\Traits\\TStringTools' not found at \/nc1\/apps\/circles\/lib\/Controller\/SharesController.php#56",
    "userAgent": "GuzzleHttp\/6.3.3 curl\/7.38.0 PHP\/7.3.10",
    "version": "16.0.3.0"
}

@theCalcaholic
Copy link

@chaptergy
I have applied your fixes to my NC intances. I could successfully create linked circles. Local sharing to a circle does work well, however the shared resources (I tested the sharing of a calendar) don't show up on the other instances. Is that what you are experiencing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants