Fork me on GitHub
#eastwood
<
2022-06-15
>
Yuner Bekir19:06:42

Hello! eastwood keeps throwing me a warning for the following lines

(apidesc
    {:id :test-webhook
     :coll-group (= [!coll :ref] "webhook")
     :data [+ (fields helper/local-fields)]
     :run (alng/http
           {:request {:api-base :http-auth
                      :path (str "/webhook/" [!settings :team-secret])
                      :method :get}
            :validate (api-lang/validate-err-code "Signl4")})})
when I remove allang/http no more errors are thrown. The error is
dl.clj:32:11: constant-test: Test expression is always logical true or always logical false: nil in form (if or__5533__auto__ or__5533__auto__ (clojure.core/or)
Thanks!

seancorfield20:06:54

What is alng aliased to? What ns/library is that from?

seancorfield20:06:04

Whatever alng/http expands to (it's a macro) has the construct that Eastwood is complaining about.

Yuner Bekir20:06:10

alng is aliesed to afw.apilang. The thing is that I use the same construct on other places and eastwood doesnt complain there

seancorfield20:06:14

Right, but it's a macro and it's going to expand to different things in different contexts. So this is a context where that macro expands to, essentially, a degenerate condition.

seancorfield20:06:43

Without seeing the source of that macro, it's hard to say what specifically is going on...

seancorfield20:06:42

I think it's the :parse expression -- ~(:parse desc) is going to cause that expression to be evaluated by the macro, yielding nil if you pass a literal hash map that doesn't contain :parse -- also, why is the alt in that or evaluated?

seancorfield20:06:25

In addition, you are potentially evaluating desc multiple times -- it would be better to bind it once to a local symbol and then use that instead.

seancorfield20:06:34

Assuming this is your macro and you can change it?

seancorfield20:06:21

I'm not entirely sure I see why this is a macro at all -- I think it could be a regular function?

seancorfield20:06:55

Ah, because you want :request in desc to be a symbolic expression and for it to be walked and have functions resolved in a different context?

Yuner Bekir20:06:45

yup for the last one, and parse is a required part of the so called apidesc, I just missed it since its getting late

Yuner Bekir20:06:01

the issue is resolved thank you soo much

seancorfield20:06:52

Might be worth adding an assert into the macro so you can't forget :parse

🙌 1