caribou / caribou-core

Core functionality for Caribou
44 stars 3 forks source link

Including a non-existent "part" throws a 500 #2

Closed miwillhite closed 12 years ago

miwillhite commented 12 years ago

Seeing this in the API, but is apparently a core issue.

Say I have a category (part), that has many products (collection).

If I request a product that doesn't have a category, yet I include categories in my request, I get an error.

e.g. /products/22?include=category

stack trace:

action: item-detail => {:slug "product", :id "22", :include "category"}
java.lang.NullPointerException
db: select * from product where id = 22
error: error rendering /product/22: java.lang.NullPointerException
action: list-all => {:slug "favicon", :format "ico"}
    at caribou.model.IntegerField.field_from(model.clj:122)
    at caribou.model$assoc_field.invoke(model.clj:363)
    at caribou.model$from$fn__2158.invoke(model.clj:373)
    at clojure.core.protocols$fn__5558.invoke(protocols.clj:64)
    at clojure.core.protocols$fn__5543$G__5538__5552.invoke(protocols.clj:11)
    at clojure.core$reduce.invoke(core.clj:5995)
    at caribou.model$from.invoke(model.clj:373)
    at caribou.model.PartField.field_from(model.clj:500)
    at caribou.model.PartField.render(model.clj:503)
    at caribou.model$fields_render$fn__2338.invoke(model.clj:717)
    at clojure.core.protocols$fn__5558.invoke(protocols.clj:64)
    at clojure.core.protocols$fn__5543$G__5538__5552.invoke(protocols.clj:11)
    at clojure.core$reduce.invoke(core.clj:5995)
    at caribou.model$fields_render.invoke(model.clj:716)
    at caribou.model$model_render.invoke(model.clj:724)
    at caribou.api.core$render.invoke(core.clj:42)
    at caribou.api.core$item_detail.invoke(core.clj:215)
    at caribou.api.core$init$fn__216.invoke(core.clj:305)
    at compojure.core$if_route$fn__48.invoke(core.clj:39)
    at compojure.core$if_method$fn__41.invoke(core.clj:24)
    at compojure.core$routing$fn__63.invoke(core.clj:98)
    at clojure.core$some.invoke(core.clj:2388)
    at compojure.core$routing.doInvoke(core.clj:98)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:602)
    at compojure.core$routes$fn__67.invoke(core.clj:103)
    at sandbar.auth$with_security$fn__1314.invoke(auth.clj:235)
    at ring.middleware.keyword_params$wrap_keyword_params$fn__1417.invoke(keyword_params.clj:27)
    at ring.middleware.nested_params$wrap_nested_params$fn__1454.invoke(nested_params.clj:65)
    at ring.middleware.params$wrap_params$fn__1391.invoke(params.clj:55)
    at ring.middleware.multipart_params$wrap_multipart_params$fn__1480.invoke(multipart_params.clj:103)
    at ring.middleware.flash$wrap_flash$fn__985.invoke(flash.clj:14)
    at ring.middleware.session$wrap_session$fn__1235.invoke(session.clj:40)
    at ring.middleware.cookies$wrap_cookies$fn__1173.invoke(cookies.clj:160)
    at sandbar.stateful_session$wrap_stateful_session_STAR_$fn__1243.invoke(stateful_session.clj:65)
    at ring.middleware.flash$wrap_flash$fn__985.invoke(flash.clj:14)
    at ring.middleware.session$wrap_session$fn__1235.invoke(session.clj:40)
    at ring.middleware.cookies$wrap_cookies$fn__1173.invoke(cookies.clj:160)
    at caribou.db$wrap_db$fn__400$fn__401.invoke(db.clj:227)
    at clojure.java.jdbc.internal$with_connection_STAR_.invoke(internal.clj:156)
    at caribou.db$wrap_db$fn__400.invoke(db.clj:227)
    at sandbar.auth$with_secure_channel$fn__1309.invoke(auth.clj:216)
    at clojure.lang.Var.invoke(Var.java:401)
    at ring.middleware.stacktrace$wrap_stacktrace_log$fn__215.invoke(stacktrace.clj:15)
    at ring.middleware.stacktrace$wrap_stacktrace_web$fn__247.invoke(stacktrace.clj:79)
    at ring.middleware.reload$wrap_reload$fn__388.invoke(reload.clj:18)
    at ring.adapter.jetty$proxy_handler$fn__87.invoke(jetty.clj:16)
    at ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler$0.handle(Unknown Source)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
prismofeverything commented 12 years ago

Alright, this is fixed in the latest caribou-core. Checking for nil anyone?