5

I am making a request with a custom filter that includes the "comment_count" field of the question type. My custom filter is !RtdMEtslKF6Z()NqpDUFZ58R6twu-.4V48gn0furqA*7_BL1.

However, when I'm querying the question having an ID of 14585943, which has no comments (at this date), the field "comment_count isn't returned by the API.

enter image description here

It should be returned, even if there are no comments, because the documentation doesn't specify that this field "may be absent".

I tested this with the even simpler filter !.UE46pK5nV.kgRss, which includes no fields, except .items, question.comment_count and question.title. The comment count still isn't returned (when the title is correctly returned).

A couple of notes that I gathered:

  • "comment_count" is correctly returned (with the correct count) by both filters above if there are comments on the question.
  • "comment_count" is always correctly returned if the filter used consists of the default filter, added with question.comment_count. In this request, the result has "comment_count":0 for questions without comments.

As such, it appears that the problem only happens when there are no comments and specific fields aren't included in the filter. (I am not sure which specific fields -- I tried to isolate to a single field but wasn't successful).

  • I can confirm this problem, had this with my filter too on some occasions. – Oldskool Aug 26 '16 at 7:55
3

This appears to be closely related to the bug: Why is comment_count=1 (incorrectly) when this particular filter is used?.

The workaround from there -- altering the filter by:

  • selecting comment.comment_id
  • and selecting question.comments

appears to work in this case too.

(Although, in at least one instance, it seemed to need question_id as well. But this could have been a caching issue, maybe.)

  • Ok this seems to work, thanks. But how come the default filter + comment_count also works? question.comments isn't included there. (Huh, I just tried and it worked without it now... I'll blame caching) – Tunaki Aug 23 '16 at 17:01
  • Something very weird is going on, start from the filter in this answer, remove question.comments, click Run, comment_count is still returned. Remove comment.comment_id, click Run, comment_count is not returned anymore. Re-add comment.comment_id, click Run, comment_count is still not returned =/ – Tunaki Aug 23 '16 at 17:06
  • See the other bug. Part of the reason to include both properties is so you don't stumble into that bug when you think you've got this bug worked around. As for the rest, it's frustrating. Queries are cached and some filters affect that and some don't, and some additional flakiness seems to be occurring too. – Brock Adams Aug 23 '16 at 17:46
  • Maybe I'll take the simpler route: if the field isn't there, it means the comment count is 0 :). Hopefully a dev will look at this, thanks again! – Tunaki Aug 23 '16 at 17:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .