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

index-exists? returns true in error #24

Open
devn opened this issue May 4, 2022 · 0 comments
Open

index-exists? returns true in error #24

devn opened this issue May 4, 2022 · 0 comments

Comments

@devn
Copy link

devn commented May 4, 2022

(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

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

1 participant