Fork me on GitHub
#pedestal
<
2021-09-15
>
lispers-anonymous17:09:50

Sounds like something in your code is expecting a vector and not a map. Not sure what without seeing the full exception. It could be this: https://github.com/v3gal0g/cybernest-xd/blob/a26dedde3eda6624b3f163c8182bbec53d05f9f0/src/clj/cybernest_xd/router.clj#L47 I'm not sure if :post/:get/etc can accept a map with an :interceptors key. I was under the impression you provide an vector of interceptors directly.

["/iota" {... :post [journal/create-iota!]}]]

v3ga17:09:38

hmm, not sure if this works. It throws the same error even as :post [journal/create-iota!] https://gist.github.com/v3gal0g/0615877edc8c81feb3e9a54236c53ec3

lispers-anonymous17:09:12

There is more to read about the terse syntax you are trying to use here: http://pedestal.io/reference/routing-quick-reference#_terse_syntax My original example seems wrong now. This may work

["/iota" {... :post `journal/create-iota!}]]
;; or
["/iota" {... :post [:create-iota `journal/create-iota!]}]] ;; s.t. :create-iota is a name given to this endpoint

lispers-anonymous17:09:49

I don't think that is your problem though

lispers-anonymous17:09:02

The exception is being thrown in an interceptor by this name: :io.pedestal.http.secure-headers/secure-headers

v3ga17:09:58

everything is public if that helps https://github.com/v3gal0g/cybernest-xd/

lispers-anonymous17:09:14

Does it work if you remove that setting? That would indicate that the value of :content-security-policy-settings you have setup is not right.

v3ga17:09:16

hmmm i’d think that would be fine since swagger and everything works… the error is thrown when I attempt to use/test “/iota” With that said i’m rather weak with both clojure and pedestal here.

lispers-anonymous17:09:52

Try to use

"default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'"

lispers-anonymous17:09:13

This is the pedestal default for that value:

"object-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:;"

v3ga17:09:09

lets see…

v3ga17:09:45

Hmm I don’t think thats it

lispers-anonymous17:09:28

What about removing the ::server/secure-headers from your service map and restarting? The error is being thrown when pedestal is trying to build those secure headers so it has to be something related to that

v3ga18:09:33

for some reason that kills swagger all together

v3ga18:09:35

yeah that blocks swagger-ui-bundle.js, etc when removed completely

lispers-anonymous18:09:04

I can't offer much advice around swagger and pedestal. I've not done any real work with the two.

v3ga18:09:12

No worries…it works now but i’m not sure whats changed. So i’ll stop here and check the diffs. Thank you though. I believe the issue was around where you mentioned. Something clearly was off.

vemv18:09:49

In case you appreciate the technique, for cases like these I do as follows: 1.- get a stacktrace 2.- use jump-to-definition 3.- strategically place debugging statements (or (assert)s) across functions described in the stacktrace 4.- take note of the precise place that passed a wrong value and fix it needs a little bit of IDE/editor mastery but it pays off so well

👍 2
v3ga18:09:55

@vemv sounds good, i’ll put that into practice. In this particular case though I’m not sure because it really didn’t seem to give you anywhere to jump to outside of the route I wanted?

lispers-anonymous19:09:28

You would have had to jump into the pedestal code itself in this particular case. Your server config was setup, then being interpreted when a request came in, so the original source of the problem was a little difficult to track down.

👍 2
lispers-anonymous19:09:22

I would encourage you to look through some of the pedestal code sometime, especially when problems pop up like this. It can be a lot at first, but I usually find it pretty straightforward to read through

v3ga20:09:07

@dannyfreeman yeah I have it saved under favorites to skim through from time to time. I actually stopped and briefly went over basics with ring. I SHOULD spend more time there but I’m a glutton for pain.

v3ga18:09:55

@vemv sounds good, i’ll put that into practice. In this particular case though I’m not sure because it really didn’t seem to give you anywhere to jump to outside of the route I wanted?

Ben Hammond20:09:31

I am running pedestal/ion-provider to support a direct http ion. I am trying to debug the CORS :io.pedestal.http/allowed-origins configuration and I am therefore interested in the log output written by

(log/info :msg "cors request processing"
                                      :origin origin
                                      :allowed allowed)
but I cannot seem to find it in cloudwatch logs; https://docs.datomic.com/cloud/ions/ions-monitoring.html#java-logging seems to imply that log/info just doesn't get written to cloudwatch events; is that true? would I normally expect the http-direct logs to be written direction into the datomic loggroup?

v3ga20:09:07

@dannyfreeman yeah I have it saved under favorites to skim through from time to time. I actually stopped and briefly went over basics with ring. I SHOULD spend more time there but I’m a glutton for pain.