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

Query returns 500 error #27

Closed
prohtex opened this issue Mar 4, 2024 · 5 comments
Closed

Query returns 500 error #27

prohtex opened this issue Mar 4, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@prohtex
Copy link

prohtex commented Mar 4, 2024

Hi there, thanks for your hard work on this client library.

I'm attempting to query a Baikal server for a single vcard based on matching email address field. This is what I have so far:

require "lib/carddav/vendor/autoload.php";

use MStilkerich\CardDavClient\{Account, AddressbookCollection, Config};
use MStilkerich\CardDavClient\Services\{Discovery};

Config::init($log, $httplog);
$account = new Account(<server>, ["username" => <username>, "password" => <pass>]);

$discover = new Discovery();
$abooks = $discover->discoverAddressbooks($account);

$abook = $abooks[0];

$contacts = $abook->query(
     ['EMAIL' => '/gmail/'],
     ['EMAIL'],
     false,
     1
);

What I'm experiencing is this: when the query returns no hits, that's fine. But when I enter something like "gmail" that I know will match many vcards, I get this error:

Exception: Expected Multistatus HTTP request was not successful (500 Internal Server Error): <?xml version="1.0" encoding="utf-8"?> <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"> <s:sabredav-version>4.5.0</s:sabredav-version> <s:exception>Sabre\Xml\ParseException</s:exception> <s:message>The input element to parse is empty. Do not attempt to parse</s:message> </d:error> in /opt/www/harkawik.com/lib/carddav/vendor/mstilkerich/carddavclient/src/CardDavClient.php on line 491

I know the credentials are working fine, but am scratching my head at this error. Please help!

@mstilkerich
Copy link
Owner

Hi, do you use Digest authentication with Baïkal? (it's the default). Then try switching to Basic Authentication (in the Baikal admin interface) and see if it fixes your issue.

See QUIRKS.md, "Internal server error on REPORTs with digest authentication" for details.

@mstilkerich
Copy link
Owner

Could you check if the latest master solves your issue?

@prohtex
Copy link
Author

prohtex commented Mar 13, 2024

Could you check if the latest master solves your issue?

It did, thank you

@mstilkerich
Copy link
Owner

I could reproduce that Baïkal would only check credentials when the query returns results, same as you experienced. Interestingly, with Nextcloud 28 using the same Sabre/DAV version authentication is required first.

I reported an issue sabre-io/dav#1548

@mstilkerich mstilkerich added the bug Something isn't working label Mar 23, 2024
mstilkerich added a commit that referenced this issue Mar 23, 2024
Have one test that runs a REPORT request on a fresh addressbook object,
so that the underlying HttpClientAdapter has not negotiated the
authentication scheme yet.
@mstilkerich
Copy link
Owner

Fixed in 1.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants