Skip to content

index-exists? returns true in error #24

Description

@devn

(s/defn index-exists? :- s/Bool
"check if the supplied ES index exists"
[{:keys [uri request-fn] :as conn} :- ESConn
index-name :- s/Str]
(not= 404
(-> (make-http-opts conn {})
(assoc :method :head
:url (index-uri uri index-name))
request-fn
:status)))

This function checks (not= 404 ...). For an example of why this is insufficient, authorization may fail (401), and thus this function will return true when in fact the specified index does not exist.

Steps to Reproduce

  1. Bring up the elasticsearch environment.
  2. Run the following in a REPL:
(require '[ductile.conn :as es.conn])
(require '[ductile.index :as es.index])

(def bad-auth-conn (es.conn/connect {:host "localhost"
                                     :port 9207
                                     :version 7
                                     :protocol :http
                                     :auth {:type :basic-auth
                                            :params {:user "wrong"
                                                     :pwd "wrong"}}}))

(es.index/index-exists? bad-auth-conn "this_index_does_not_exist") ;; => true

Affects version: 0.4.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions