Repository navigation
Description
remark: this issue is regarding the regarding the OCS v2 draft 1 specification. please refer to OCS v2.draft1 comments overview for further information.
reading the specification, i got sometimes confused if the mentioned status code refers to a http status code or to an OCS status code (see #21174).
furthermore i think the fact, that the http code is always required to be 200 makes it more difficult for the consumer to handle the results, as it might also get other http-codes generated by the server when accessing a resource (30x, 4xx, 5xx). thus, the consumer has to inspect both codes to work reliably.
in my e-mail to @karlitschek i suggested to use http status codes in order to be consistent with cases, when the server would generate a message, without the OCS component to be involved.
i further suggested to use reserved ranges of status codes for the generic service infrastructure (e.g. authentication, service location, ...) and an other range for service specific errors. to avoid confusion with the http codes, it might be considerate to use codes only above 599. instead of the proposed ranges in the e-mail mentioned, it might make sense to use a different scheme, but related to the http code classes (see Section 6 of RFC7231), e.g.
- Informational
1xxxfor generic errors1xxxxfor service errors
- Successful
2xxxfor generic errors2xxxxfor service errors
- Redirection
3xxxfor generic errors3xxxxfor service errors
- Client Error
4xxxfor generic errors4xxxxfor service errors
- Server Error
5xxxfor generic errors5xxxxfor service errors
thus the range 1000-5999 should be specified by the standard. everything as of 10000 in the appropriate service specification.
i suggest that in the specifications, the error codes are always specified in the notation of xxx/yyyy[z], where xxx represents the http status code, while the yyyy or yyyyz stands for the OCS generic or service status code respectively.
- moved permanently (
301/-) and permanent redirection (308/-)- by the server:
- MUST be sent as http
308status code (since the method should not be changed), - MAY include a OCS response (which whould differ from a server-generated redirection)
- MUST be sent as http
- by the consumer
- SHOULD be followed by, and
- access information SHOULD be updated accordingly
- by the server:
- temporary redirection (
307/-)- by the server
- MUST be sent as http
307status code, - MUST NOT include a OCS response
- MUST be sent as http
- by the consumer
- SHOULD be followed,
- while access information MUST NOT be updated
- by the server
- malformed requests
- if the http-request itself is malformed, the server (
400/-)- MUST send a http
400error - MUST NOT include a OCS response (won't, as it is generated by the server)
- MUST send a http
- in case of malformed payload (
400/4xxx[z])- the http
400error needs to be sent by the script - an OCS response SHOULD be included, e.g. with
400/4001data does not comply to application/x-www-form-urlencoded400/4002missing mandatory parameters400/4003unknown parameters
- the http
- in case of an unknown resource (eg. an unexisting
{store}or{key}inPRIVATE_DATA)- the http code
403MUST be used - (a
404seems more intuitive, but rfc2616 states: "This status code is commonly used when the server does not wish to reveal exactly why the request has been refused (...).") - an OCS response SHOULD be included, e.g. with
403/40001store not found403/40002key not found
- the http code
- in case of too many components of the URI
- the http cod
501MUST be used - an OCS response SHOULD be included, e.g. with
501/5000function or method not implemented501/5001protocol version not implemented501/5002service not implemented (a consumer should not rediscover the service, as the response is "authoritative". if a consumer gets a404instead - maybe on a previously working URL - it should rediscover the service url instead as it might have moved without30x)501/50001service X: method not implemented
- the http cod
- if the http-request itself is malformed, the server (
- Unauthorized requests (
401/4XXX?)- http
401MUST be sent as http status code, 4000OCS response MAY be included (not sure if http standard allows that for a401response)
- http
- the following situations would also cause a http
403- if a resource is correct, but
- access denied or
- data not available (eg. store not existing in
PRIVATE_DATA, see above),
- and OCS response SHOULD be included
- if a resource is correct, but
- http
404will be sent by the webserver, if the resource is not available. the consumer SHOULD try to rediscover the resource using the service locator procedure - http
410SHOULD be sent, if a share has been unshared or rejected. (this implies, that re-sharing the same resource would require a newremoteId.) - http
503SHOULD be sent eg. in maintenance mode, an OCS response MAY be included (eg. with the announcement, see https://apps.owncloud.com/content/show.php/Announcement+Center?content=173921), or e.g.503/5011back-end unavailable503/5012back-end maintenance
this seems all very complicated. but it makes it more consistent for the client, e.g. in the case a resource is accessed which is not actually an OCS resource or the webserver generates the error before processing the script.
maybe the above rules need a revision, it would be easier to create a table with the conditions and both the http and OCS status codes.
Activity
LukasReschke commentedon Mar 1, 2016
Subscribing myself here.
DeepDiver1975 commentedon Jan 27, 2017
To some extend the API specification is continued here: https://github.com/GEANT/OCM-API
lock commentedon Aug 3, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.