Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 internal server error when clicking into an article #75

Closed
MrOrz opened this issue Jan 17, 2018 · 1 comment
Closed

500 internal server error when clicking into an article #75

MrOrz opened this issue Jan 17, 2018 · 1 comment

Comments

@MrOrz
Copy link
Member

MrOrz commented Jan 17, 2018

Visit: https://cofacts.g0v.tw/article/AWEET-BFyCdS-nWhunGr

TypeError: Cannot read property 'set' of null
    at /srv/www/.next/dist/ducks/articleDetail.js:182:35
    at /srv/www/node_modules/immutable/dist/immutable.js:3016:46
    at List.__iterate (/srv/www/node_modules/immutable/dist/immutable.js:2206:13)
    at IndexedIterable.mappedSequence.__iterateUncached (/srv/www/node_modules/immutable/dist/immutable.js:3015:23)
    at seqIterate (/srv/www/node_modules/immutable/dist/immutable.js:604:16)
    at IndexedIterable.IndexedSeq.__iterate (/srv/www/node_modules/immutable/dist/immutable.js:320:14)
    at IndexedIterable.toArray (/srv/www/node_modules/immutable/dist/immutable.js:4258:23)
    at List [as constructor] (/srv/www/node_modules/immutable/dist/immutable.js:2065:62)
    at reify (/srv/www/node_modules/immutable/dist/immutable.js:3570:37)
    at List.map (/srv/www/node_modules/immutable/dist/immutable.js:4401:14)

L172 - 197

return state.withMutations(function (s) {
    return s.updateIn(['data', 'article'], function (article) {
      return (article || (0, _immutable.Map)()).merge(payload.remove('replyConnections').remove('relatedArticles'));
    }).setIn(['data', 'replyConnections'], payload.get('replyConnections')).updateIn(['data', 'relatedArticles'], function (articles) {
      return !relatedArticleEdges.size ? articles : relatedArticleEdges.map(function (edge) {
        return edge.get('node').remove('replyConnections');
      });
    }).updateIn(['data', 'relatedReplies'], function (replies) {
      return !relatedArticleEdges.size ? replies : relatedArticleEdges.flatMap(function (edge) {
        return edge.getIn(['node', 'replyConnections']).map(function (conn) {
          return conn.get('reply').set('article', edge.get('node').remove('replyConnections'));
        }).filter(function (reply) {
          // Filter-out replies that is already re-used.
          return reply && !replyIds.contains(reply.get('id'));
        });
      })
      // De-duping replies using replyId, taking the reply with more relavant article
      // (which should come first)
      //
      .groupBy(function (reply) {
        return reply.get('id');
      }).map(function (replyGroup) {
        return replyGroup.first();
      }).toList();
    });
  });

L182: return conn.get('reply').set('article', edge.get('node').remove('replyConnections'));

@MrOrz
Copy link
Member Author

MrOrz commented Jan 17, 2018

Cause: When invoking CreateReplyConnection, it does not check if the given replyId exists.

It is recovered by manually removing the replyConnection and the replyConnectionId from the affected articles (5480022804100-rumor).

When implementing CreateReplyConnection we should check if the reply exists in the future.

@MrOrz MrOrz closed this as completed Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant