Fix infinite recursion when serializing object loops.

Review Request #6095 — Created July 10, 2014 and submitted

Information

Djblets
master
e0cec5a...

Reviewers

If two objects reference each other, and the relevant fields are listed in the
'expand' parameter, the serialization of the response would get a recursion
depth RuntimeError and return 500. This manifested in Review Board using the
"Depends On" field, with two review requests that referenced each other.

I've added some code to make each resource name in "expand" apply only once
for the entire serialization. This makes it possible to still expand deep into
object trees, but prevents infinite loops. To expand multiple levels with the
same resource name, it can be listed twice in 'expand'.

  • Tested setting a review request's "Depends On" to itself.
  • Tested a loop of two objects in "Depends On".
  • Tested recursing multiple levels via:
    curl /api/review-requests/1/?expand=depends_on,depends_on | python -mjson.tool
Description From Last Updated

can we change this to _djblets_webapi_expanded_resources? Been prefixing other Djblets things on request with similar prefixes.

chipx86chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources.py
    
    
  2. 
      
chipx86
  1. 
      
  2. djblets/webapi/resources.py (Diff revision 1)
     
     
    Show all issues

    can we change this to _djblets_webapi_expanded_resources? Been prefixing other Djblets things on request with similar prefixes.

  3. 
      
david
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/resources.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/resources.py
    
    
  2. 
      
chipx86
  1. Ship It!

  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-0.8.x (85eb686)