508

Loop Detected

5xx Server Error

ELI5

The server followed references while walking through folders and found a cycle, so it stopped instead of going in circles forever.

Server perspective

Use 508 when a WebDAV operation fails because the server detected an infinite loop while traversing resources.

When to use

  • Return 508 when a recursive or Depth: infinity operation cannot finish due to cyclic bindings or references
  • Use it when the entire operation fails because loop detection is required to prevent unbounded traversal
  • WebDAV Depth: infinity operations encounter cyclic bindings or recursive references
  • Collection traversal would loop forever without explicit detection
  • The server must stop the entire operation because the requested graph of resources is cyclic

How to respond

  • Track visited resources or bindings during traversal so loops are detected deterministically
  • Prefer 208 Already Reported inside Multi-Status when you can complete the response safely without repeating members

Headers to consider

  • No status-specific header is required; standard WebDAV response metadata may still apply

Response body

  • A body is recommended; explain that a cyclic reference or traversal loop was detected and include enough safe detail for operators or clients to find the offending structure

Server-side pitfalls

  • Do not use 508 for ordinary deep trees that are merely slow but not cyclic
  • Do not use 508 when duplicate suppression with 208 Already Reported would let the operation succeed
  • The server can complete the operation and suppress duplicates inside a Multi-Status response (consider 208 Already Reported)
  • A single resource is locked or unavailable for other reasons (use a more specific WebDAV status such as 423 Locked)
  • Generic server failures unrelated to cyclic traversal (use 500 Internal Server Error or another specific 5xx)

Examples

Recursive WebDAV traversal hits cyclic binding

Request:PROPFIND https://api.example.test/collection
Response:508 Loop Detected # Headers Content-Type: application/json # Body { "error": "loop_detected" }

The server discovered a reference cycle while enumerating the collection tree and aborted the request.

References

Related Status Codes