[jboss-jira] [JBoss JIRA] (AS7-4977) Api returns internal server error instead of not found for non-exiting path

Ian Springer (JIRA) jira-events at lists.jboss.org
Mon Jun 11 16:44:04 EDT 2012


    [ https://issues.jboss.org/browse/AS7-4977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12700597#comment-12700597 ] 

Ian Springer commented on AS7-4977:
-----------------------------------

+1. 

>From the HTTP 1.1 spec:

10.4 Client Error 4xx

The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user. 

<snip>

10.5 Server Error 5xx

Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has erred or is incapable of performing the request. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. User agents SHOULD display any included entity to the user. These response codes are applicable to any request method.

10.5.1 500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request. 

<snip>


Based on these definitions, neither 500 nor any 5xx code is appropriate to return when the client requests a non-existent management resource. It's a client error, so a 4xx code should be returned. 400 (Bad Request) is probably the best fit out of the spec-defined client error codes. 404 ("The server has not found anything matching the Request-URI") isn't ideal since the request URI (/management) is perfectly valid; it's the request body that has issues.

Unfortunately, always returning a 400 does not give the client any way to distinguish between different types of client errors (e.g. mgmt resource not found, invalid attribute or operation name). There are a couple ways we could provide the client with a more specific status:

1) Define some custom 4xx codes, e.g.:

490: Management resource not found
491: Management attribute not found
492: Management operation not found

or IIS-style:

400.1: Management resource not found
400.2: Management attribute not found
400.3: Management operation not found

2) Return a 400 response but include a custom HTTP header with a sub status code which gives a more detailed description of the client error, e.g.:

JBoss-Status-Subcode: 1 Management resource not found
JBoss-Status-Subcode: 2 Management attribute not found
JBoss-Status-Subcode: 3 Management operation not found

                
> Api returns internal server error instead of not found for non-exiting path
> ---------------------------------------------------------------------------
>
>                 Key: AS7-4977
>                 URL: https://issues.jboss.org/browse/AS7-4977
>             Project: Application Server 7
>          Issue Type: Bug
>          Components: Domain Management
>    Affects Versions: 7.1.2.Final (EAP)
>            Reporter: Heiko Rupp
>            Assignee: Brian Stansberry
>              Labels: rhq
>
> When I try to e.g. /subsystem=foo:read-resource the api returns a 500 internal server error.
> In http-land, the return code for "not found" is normally 404.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list