Fork me on GitHub
#pedestal
<
2017-01-20
>
ddellacosta18:01:38

so I’m seeing some really bizarre behavior that I can’t wrap my head around

ddellacosta18:01:47

I’ve got enter and leave interceptors set up

ddellacosta18:01:10

and I have logging in both of those, and those calls are getting hit—I see the request go through

ddellacosta18:01:30

but the response is a 404 response. I am just completely stumped as to what is going on or how to debug it at this point.

ddellacosta18:01:38

has anyone seen this?

ddellacosta18:01:20

I’m on the latest, 0.5.2, using jetty

ddeaguiar18:01:01

@ddellacosta without seeing any code I can only guess that you're not assoc'ing a response to the context. Did you set up a handler for the route?

ddellacosta19:01:04

@ddeaguiar yes, I’ve got an :enter interceptor handler set up

ddellacosta19:01:18

it dumps out a logging message, which I see, and assocs a b.s. response map to the context

ddellacosta19:01:27

but still I’m getting a 404 for some reason

ddellacosta19:01:53

I must be doing something incredibly basically stupid here but I can’t for the life of me figure out what it is

ddeaguiar19:01:41

Can you share a code snippet for your interceptor as well as the routes?

ddeaguiar19:01:03

So the default not-found interceptor checks the context for a response. If none is present then a 404 is returned

ddellacosta19:01:08

Sorry for the confusing layout and formatting; basically the top half is the interceptor code and configuration, the bottom bit is the test I’m running it within, and the fixture that starts and stops the server

ddellacosta19:01:41

I can only imagine that somehow it’s behaving as you suggest, and it’s not finding the response, but I can’t see how

ddellacosta19:01:09

what I see in my output, among other things, is the response:

12│  ??  {:request-time 6, :repeatable? false, :protocol-version {:name HTTP, :major 1, :minor 1}, :streaming? true, :chunked? false, :reason-phrase Not Found, :headers {Connection close, Date Fri, 20 Jan 2017 19:06:49 GMT, Content-Type text/plain}, :orig-content-encoding nil, :status 404, :length -1, :body Not Found, :trace-redirects []}

ddellacosta19:01:24

and, the logging message (”this shows up”)

ddeaguiar19:01:39

try adding :status 200 to the response map

ddeaguiar19:01:59

which checks that the response is a map and that status is an integer

ddellacosta19:01:24

apparently that was it

ddellacosta19:01:36

I knew it was something incredibly stupid

ddellacosta19:01:58

and, thanks for the pointers to the relevant code

ddeaguiar19:01:01

Well, I think there may be some opportunity to improve messaging

ddellacosta19:01:14

yeah, this cost me almost half a day, it was very frustrating

ddeaguiar19:01:20

sorry to hear that

ddellacosta19:01:22

and it was an incredibly basic mistake

ddeaguiar19:01:36

I do have some suggestions for you

ddellacosta19:01:42

part of that is probably that I failed to read the necessary docs on how you should add responses to the context though

ddellacosta19:01:56

wherever those are…I’m pathological about reading docs after the fact

ddeaguiar19:01:21

1. construct responses using ring's response helper

ddellacosta19:01:22

but yeah, suggestions welcome...

ddeaguiar19:01:13

2. prefer simple handler fns over interceptors for returning responses

ddeaguiar19:01:40

Docs can be found here: http://pedestal.io/. Requests for improvement welcome

ddellacosta19:01:08

got it—thanks for those tips, and I’ll take the time to actually read the docs now. All your help is much appreciated @ddeaguiar !

ddeaguiar19:01:21

np! Good luck!

ddellacosta19:01:48

oh and yeah, as far as improving messaging I suppose it would have been super helpful if pedestal had dumped out something like, “hey dumbass, there is not a response map/your response map is missing some basic stuff…” Granted, I should have known, but I guess I was kind of assuming that pedestal would magically merge stuff in somehow. Thinking back on it I don’t know why I thought that, and the behavior I was seeing makes a ton of sense now, but a warning or something would have been great.