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

Invalid URI constructed [//_bulk] #501

Closed
kaiwa opened this issue Nov 27, 2013 · 5 comments
Closed

Invalid URI constructed [//_bulk] #501

kaiwa opened this issue Nov 27, 2013 · 5 comments

Comments

@kaiwa
Copy link

kaiwa commented Nov 27, 2013

Bulk.php

120     public function getPath()
121     {
122         $path = '/';
123         if ($this->hasIndex()) {
124             $path.= $this->getIndex() . '/';
125             if ($this->hasType()) {
126                 $path.= $this->getType() . '/';
127             }
128         }
129         $path.= '_bulk';
130         return $path;
131     }

So getPath() returns /_bulk if Bulk::hasIndex() is false.

Later in Transport/Http.php:

        if (!empty($url)) {
            $baseUri = $url;
        } else {
            $baseUri = $this->_scheme . '://' . $connection->getHost() . ':' . $connection->getPort() . '/' . $connection->getPath();
        }

        $baseUri .= $request->getPath();

This code will construct the uri with an additional slash if $connection->getPath() returns an empty string:

$baseUri = http://localhost:9200//_bulk

Resulting in No handler found for uri [//_bulk] and method [PUT]

@kaiwa
Copy link
Author

kaiwa commented Nov 27, 2013

Btw, ResponseSet for this is the following one. I'm not that familar with the internals of this lib, shouldn't it be an error response or even throw an exception (i've just noticed it is saying _error => false)?

object(Elastica\Bulk\ResponseSet)#114 (7) {
  ["_bulkResponses":protected]=>
  array(0) {
  }
  ["_position":protected]=>
  int(0)
  ["_queryTime":protected]=>
  NULL
  ["_responseString":protected]=>
  string(0) ""
  ["_error":protected]=>
  bool(false)
  ["_transferInfo":protected]=>
  array(0) {
  }
  ["_response":protected]=>
  array(1) {
    ["message"]=>
    string(51) "No handler found for uri [//_bulk] and method [PUT]"
  }
}

@ruflin
Copy link
Owner

ruflin commented Dec 1, 2013

I hope I could resolve the first issue with my last commit (see above)

@ruflin
Copy link
Owner

ruflin commented Dec 1, 2013

About the error / exception. I agree that there should be an exception. I think the problem is, that the error is in the "reponse" and not in the "bulkResponse". And if there is already and error in the response occurs is in this case not checked. I have to take a close look into this.

@kaiwa
Copy link
Author

kaiwa commented Dec 1, 2013

Yep that fixed it, thanks for your quick action.

@kaiwa
Copy link
Author

kaiwa commented Dec 3, 2013

I will close this one for the sake of clarity and open another issue for the error / exception thing.

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

No branches or pull requests

2 participants