pluralsight / guides-cms

DEPRECATED - Markdown based CMS with Github repository as persistent storage
http://www.pluralsight.com/guides/
GNU Affero General Public License v3.0
108 stars 35 forks source link

Errors when editor changes stack of guide they do not own #107

Closed durden closed 7 years ago

durden commented 7 years ago

We should now allow anyone but the original author change the stack of a guide. Currently this is allowed and results in errors. To reproduce:

  1. Edit someone else's guide
  2. Change the stack
  3. See errors
durden commented 7 years ago

Here's an example of what happens:

[master 0f5ff57] "Moving 'Conditional Logic in C# .NET' from in-review/other/conditional-logic-in-c-net to in-review/microsoft-net/conditional-logic-in-c-net" 
   2 files changed, 0 insertions(+), 0 deletions(-) 
   rename in-review/{other => microsoft-net}/conditional-logic-in-c-net/article.md (100%) 
   rename in-review/{other => microsoft-net}/conditional-logic-in-c-net/details.json (100%) 
  To https://pluralsight:cc65d499e0985ee1c0850ff0d5d5d3f55fd5d26f@github.com/pluralsight/guides.git 
     8823a5b..0f5ff57  master -> master 
  2017-04-09 21:06:45,120 WARNING [in /app/pskb_website/remote.py:353]: Failed reading file details at "repos/pluralsight/guides/contents/in-review/other/conditional-logic-in-c-net/article.md", status: 404, branch: master, data: {u'documentation_url': u'https://developer.github.com/v3', u'message': u'Not Found'}  
  2017-04-09 21:06:45,121 ERROR [in /app/pskb_website/models/article.py:341]: Failed reading path: "pluralsight/guides/in-review/other/conditional-logic-in-c-net/article.md" branch: master  
  2017-04-09 21:06:45,122 ERROR [in /app/.heroku/python/lib/python2.7/site-packages/flask/app.py:1423]: Exception on /api/save [POST]  
  Traceback (most recent call last): 
    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app 
      response = self.full_dispatch_request() 
    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request 
      rv = self.handle_user_exception(e) 
      return wrapped(*args, **kwargs) 
    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception 
      reraise(exc_type, exc_value, tb) 
    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request 
      rv = self.dispatch_request() 
    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request 
      return self.view_functions[rule.endpoint](**req.view_args) 
      return wrapped(*args, **kwargs) 
    File "/app/pskb_website/lib.py", line 83, in decorated_function 
      return func(*args, **kwargs) 
    File "/app/pskb_website/api.py", line 111, in api_save 
      first_commit=first_commit) 
    File "/app/pskb_website/models/article.py", line 584, in branch_or_save_article 
      image_url, author_real_name=author_real_name) 
    File "/app/pskb_website/models/article.py", line 537, in branch_article 
      stacks=article.stacks, status=article.publish_status) 
    File "/app/pskb_website/models/article.py", line 459, in save_article 
      commit_sha = save_branched_article_meta_data(article, author_name, email) 
    File "/app/pskb_website/models/article.py", line 728, in save_branched_article_meta_data 
      if branch_info in orig_article.branches: 
  AttributeError: 'NoneType' object has no attribute 'branches' 
  2017-04-09 21:06:48,110 INFO [in /app/pskb_website/tasks.py:150]: Moving Conditional Logic in C# .NET from in-review/other/conditional-logic-in-c-net to in-review/microsoft-net/conditional-logic-in-c-net  
durden commented 7 years ago

Here's an example commit of where this happened commit.

The move of the guide worked, but the metadata was not updated because we moved the file on the master branch and then tried to branch the guide to the editor's branch. This failed because the guide was moved on master.