users@jersey.java.net

[Jersey] Why a 404 instead of 400 on bad query parameters?

From: <java.net_at_jasonerickson.com>
Date: Fri, 24 Dec 2010 00:40:49 +0000 (GMT)

I have a service defined thus:
        @GET
        public Observation[] getObservations(
                        @QueryParam("startDate") Date startDate,
                        @QueryParam("endDate") Date endDate,
                        @QueryParam("observerId") Long observerId,
                        @QueryParam("observerName") String
observerName,
                        @QueryParam("subjectId") Long subjectId,
                        @QueryParam("subjectName") String subjectName,
                        @QueryParam("phenomenonId") Long phenomenonId,
                        @QueryParam("page") @DefaultValue("0") int
page,
                        @QueryParam("pageSize") @DefaultValue("25") int
pageSize,
                        @QueryParam("excludeLocationless")
@DefaultValue("false") boolean excludeLocationless) {
          ... do some stuff
        }

A client was passing 27.0 for observerId and was getting a 404 error.
Naturally, he assumed that either the path to resource was invalid or
that 404 meant that there were no results. But the problem was that
27.0 was not a Long. If he passed observerId=27, he did get results.

My question is: Does this make sense? Wouldn't a 400 be more
appropriate? Is this because of the JSR? Or should I log it as a bug?