last day (15 days later) » 

10:12 PM
-1
Q: API returns reputation history events for deleted posts, yet no post_deleted events are included. Why? Bug? What do I do?

avm23This SE API request for user 30382 of Mathematics site returns the following items: ... {"reputation_history_type":"post_downvoted","reputation_change":-2,"post_id":4949321,"creation_date":1721723662,"user_id":30382}, {"reputation_history_type":"post_upvoted","reputation_change":10,"post_id":4949...

user1502910
Are you sure rephistory is retroactively updated when a post is deleted? Would it really make sense to delete these rows, in case the post gets undeleted? Rephistory is like an audit trail, and it represents what happened to the user's rep at the time; I can't imagine it's what's used to calculate a user's reputation - which would have been adjusted after the post was deleted. The answer you link to only talks about what happens to the user's reputation, not what happens to the historical record of the user's reputation.
user1502910
I would expect to see, for example, an item in the reputation history to represent what happened to the user's rep when the post was deleted. Perhaps the API filters only to specific types.
@testing-for-ya Good questions and good points. There are post_deleted and post_undeleted rephistory types, which I haven't seen. Because of this, I assumed that these were only for private events like voter_downvotes, and public events are filtered out somehow. It could be the case that rephistory is a "permanent" ledger, and post_deleted should account for all changes.
user1502910
Yeah, I think if the post_deleted events were public, I would expect it to show up in your API query, along with the up and down votes before the post was deleted. If it were in the output, I bet it would show the reversal of the reputation earned.
I also assumed that the filtering of private events from rephistory API is similar to SEDE/dump Votes table, where votes for deleted posts are removed along with all private votes. The API documentation says: "Certain reputation events are private (and types may be reclassified as policy changes), so totaling a user's reputation history may not match their reported reputation unless you have access to their entire reputation history." It looks like API developers decided to zealously censor all post_deleted events, be they for voter_upvotes or post_upvoted.
user1502910
10:12 PM
If that is the case, you could argue that reputation history for posts that have been deleted should not be included, since they'll all have that reversal effect - except for those that get to keep rep due to age/score, which... I don't know how that edge case would get recorded. I imagine that would make the API query a lot more complex.
To everyone: Is it possible to keep at least some post_deleted events public without risking to disclose "private" rephistory events?
user1502910
I'm sure it's possible, but it would require a change on their side I believe. I don't know how changes are made to the queries behind API methods, but I suspect they're not taken lightly because they can break existing code.
@testing-for-ya I believe all edge cases are considered in SE internal system, but I doubt it has a public/private distinction baked in. I guess, they filter private/public events only at the interfaces like SEDE, dump, API, and Web. Interestingly, Web reputation page does not include these rephistory events for the deleted post. So maybe the same thing can be done for the API endpoint at a low cost from SE side?
Not a bug. This is status-bydesign. Those events exist, and always remain. They are visible in your reputation history, if you click the "show removed posts" checkbox that is at the bottom of your reputation page. There are corresponding events where the reputation is removed. Deleting a post doesn't retroactively remove the reputation changes. It adds a reputation change entry at the time the post is deleted, if the reputation isn't retained. Reputation is retained for posts that are deleted with a score >= 3 and which have been on the site >= 60 days.
@Makyen Can't tell if you are a staff member, but anyways, do you think the same filtering logic can potentially be implemented as feature for reputation-history API, as is in place for users' reputation page? Update for the context: As I mentioned 1 comment above, the reputation page somehow takes post deletion into account and filters out private events for an outside observer at the same time, while API does the latter but not the former.
10:12 PM
@avm23 I'm not a staff member. I don't see how having that as a function of the API is desirable. The consumer of the API data can always filter out whatever portion of the data they don't want to present (e.g., they could implement a similar checkbox), if they want to. That's really not a function to push down into an API. Maybe I'm misunderstanding what you're intending/wanting.
@avm23 Those events are not private. That information (at least aggregated by day, if not with an exact timestamp) is available from the base site UI to any user with the view deleted posts privilege. The private events are already filtered out from that endpoint. The reputation events that are private are already only available from the /users/{id}/reputation-history/full endpoint, which is only available for the account associated with the access_token used with the request.
@Makyen As an API consumer I want as much information as possible. This would include knowing what reputation adjustments have been made due to post deletion, i.e. post_deleted events. My current understanding is that post_deleted events are blanket censored from the public API output, because they may leak private data (e.g. tell if a user downvoted a post, because -1 would be refunded afaic). If it were easy to tell which post_deleted leak private data and which don't, then I suppose API would include the non-leaking events.
@Makyen "Those events are not private. That information (at least aggregated by day, if not with an exact timestamp) is available from the base site UI to any user with the view deleted posts privilege." Which events precisely? Are you able to see my downvote refunds for deleted posts then? (If I had any?)
user1502910
Well, @Makyen can tell us what he sees for my reputation on July 18th, when I received a refund when a post was deleted. I can't even see that for myself without checking the "show removed posts" box.
@testing-for-ya That event is private and is not included in /2.3/users/1502910/reputation-history?pagesize=100&site=meta‌​. That is not the type of event that's discussed in this question. What is and is not private is very specific and detail-oriented. Very close care and attention needs to be applied to what is and is not private and what is being discussed here.
@testing-for-ya To be more specific: That (I assume) is a refund for the cost of you downvoting on an answer. Both the cost to you of you downvoting and the refund of such cost when the post is deleted is private. That information is not even shown to moderators (although everyone can estimate the total difference, based on public information). Such events are not available to anyone other than you, even through the SE API. The -2 reputation change caused by that vote to the author of the answer you downvoted is, however, public, as is the refund of that -2 when the post is deleted.
@Makyen No, this is the type of event that is discussed in this post now. Thanks to many clues that you and @testing-for-ya generously provided, the question has naturally evolved from "why do I get events that should be cancelled (post_upvoted)" to "why do I not get events (post_deleted) that signify that other events (post_upvoted) should be cancelled". I hope we all are on the same page now.
avm23 NO the event which @testing-for-ya is asking about is absolutely not an event which this question is asking about. They are asking about receiving a +1 refund for the cost of downvoting an answer that they are not the author of. That is definitely not what this question is asking about. This question is about reputation events for posts for which the person is the author. The event they are asking about is a private event and never included in /users/{ids}/reputation-history.
@avm23 The question has not been edited, thus it is, by definition, not changed from its original version. That there's a discussion in comments doesn't change the content of the question. If you want the content of the question to change, then you need to edit it (which you're welcome to do, particularly given that nobody's posted an answer).
10:12 PM
@Makyen I was about to edit it. I am a slow typist. :-)
@avm23 I appreciate the edit. The question, however, retains the misconception of events being "canceled". Events (under normal conditions) are not canceled. If you remove that misconception from the question, and in particular, the title, this would be a much better question. Your point that there are no post_deleted events is reasonable. I suggest focusing the question on those being missing.
As to what to do: You will probably need to separately determine which posts of the user's are not deleted (i.e., get their list of posts), potentially from /users/{ids}/posts (or other endpoint). That should tell you which posts of theirs are not deleted. As far as I'm aware, there's no way to determine the timestamp for the deletion from the SE API. You can determine that the post exists and is deleted, but the only way I'm aware of requires an access_token and the account associated with the access_token having a profile on the site on which the post you're interested in might exist.
user1502910
@Makyen You're right, I got the vote direction backwards. I still have an example for comparison; on Jun 2 I deleted a question that had one upvote and 6 downvotes. Here's what I see. What do you see? (Anyway, I think I understood the spirit of the OP's issue all along - they don't think voting information on a user's deleted post should bother being included in the reputation history.)
@testing-for-ya On your reputation page I see no events on 2024-06-02. [A moderator would be shown those events, as they are not considered private.] However, I can see the public information in the timeline for your question "Let’s stop deleting wrong-site off-topic questions so quickly" that you received 1 upvote and 6 downvotes on that question on that day and that the question was deleted on that day, reversing the net reputation gain.
So, as I said, the reputation changes are public and available from the stock UI. Note: it's the fact that the votes were cast that day on your post that's publicly available from the site UI. The actual reputation change has to be computed, but there's enough information to do so, except when the user might have had 1 reputation and a negative event, as the order of the votes might matter. The things that are not available from the stock UI, except to the user and moderators, is the timestamp within the day for each of the votes. Yes, it's not as convenient, but the information is there.
user1502910
@Makyen A complication in addition to 1 rep is if voting straddles midnight UTC and the user has hit the rep cap. Probably not common for someone to hit the rep cap and also delete a post, but... not impossible.
@Makyen How exactly have you figured out which deleted question testing-for-ya had in mind and obtained its post id or link?
@testing-for-ya For the record, reputation-history publicly shows 7 events: 6 post_downvoted and 1 post_upvoted for post id 400405. It does not show that the post was deleted and whether you got to keep the reputation (in this case negative). At the same time, your user reputation page and reputation API shows publicly that there were no reputation changes for this post.
10:12 PM
@avm23 In that case, because a largely-unidentified specific post was being asked about, which wasn't identified as either a question or answer, I used the link I'd included in a comment above to re-get testing-for-ya's reputation history for that day, which gave me the post ID. That was, however, just the most convenient method. Without that information, it would be possible to find it by looking at other artifacts, or, worst case, looking through all deleted posts created on or around that day (might have needed to expand search to more days, depending on what happened).

last day (15 days later) »