Skip to content

OCS v2.draft1: status codes #21175

Closed
Closed

Description

@martin-rueegg

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
    • 1xxx for generic errors
    • 1xxxx for service errors
  • Successful
    • 2xxx for generic errors
    • 2xxxx for service errors
  • Redirection
    • 3xxx for generic errors
    • 3xxxx for service errors
  • Client Error
    • 4xxx for generic errors
    • 4xxxx for service errors
  • Server Error
    • 5xxx for generic errors
    • 5xxxx for 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 308 status code (since the method should not be changed),
      • MAY include a OCS response (which whould differ from a server-generated redirection)
    • by the consumer
      • SHOULD be followed by, and
      • access information SHOULD be updated accordingly
  • temporary redirection (307/-)
    • by the server
      • MUST be sent as http 307 status code,
      • MUST NOT include a OCS response
    • by the consumer
      • SHOULD be followed,
      • while access information MUST NOT be updated
  • malformed requests
    • if the http-request itself is malformed, the server (400/-)
      • MUST send a http 400 error
      • MUST NOT include a OCS response (won't, as it is generated by the server)
    • in case of malformed payload (400/4xxx[z])
      • the http 400 error needs to be sent by the script
      • an OCS response SHOULD be included, e.g. with
        • 400/4001 data does not comply to application/x-www-form-urlencoded
        • 400/4002 missing mandatory parameters
        • 400/4003 unknown parameters
    • in case of an unknown resource (eg. an unexisting {store} or {key} in PRIVATE_DATA)
      • the http code 403 MUST be used
      • (a 404 seems 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/40001 store not found
        • 403/40002 key not found
    • in case of too many components of the URI
      • the http cod 501 MUST be used
      • an OCS response SHOULD be included, e.g. with
        • 501/5000 function or method not implemented
        • 501/5001 protocol version not implemented
        • 501/5002 service not implemented (a consumer should not rediscover the service, as the response is "authoritative". if a consumer gets a 404 instead - maybe on a previously working URL - it should rediscover the service url instead as it might have moved without 30x)
        • 501/50001 service X: method not implemented
  • Unauthorized requests (401/4XXX?)
    • http 401 MUST be sent as http status code,
    • 4000 OCS response MAY be included (not sure if http standard allows that for a 401 response)
  • 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
  • http 404 will 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 410 SHOULD be sent, if a share has been unshared or rejected. (this implies, that re-sharing the same resource would require a new remoteId.)
  • http 503 SHOULD 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/5011 back-end unavailable
    • 503/5012 back-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

  1. LukasReschke commented on Mar 1, 2016

    @LukasReschke
    Contributor

    Subscribing myself here.

  2. DeepDiver1975 commented on Jan 27, 2017

    @DeepDiver1975
    Contributor
  3. lock commented on Aug 3, 2019

    @lock

    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.

  4. locked as resolved and limited conversation to collaborators on Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions