{"action":"created","issue":{"url":"https://api.github.com/repos/dj-stripe/dj-stripe/issues/530","repository_url":"https://api.github.com/repos/dj-stripe/dj-stripe","labels_url":"https://api.github.com/repos/dj-stripe/dj-stripe/issues/530/labels{/name}","comments_url":"https://api.github.com/repos/dj-stripe/dj-stripe/issues/530/comments","events_url":"https://api.github.com/repos/dj-stripe/dj-stripe/issues/530/events","html_url":"https://github.com/dj-stripe/dj-stripe/issues/530","id":238086491,"number":530,"title":"Received 'invoice.upcoming' webhook","user":{"login":"lskillen","id":2248287,"avatar_url":"https://avatars1.githubusercontent.com/u/2248287?v=3","gravatar_id":"","url":"https://api.github.com/users/lskillen","html_url":"https://github.com/lskillen","followers_url":"https://api.github.com/users/lskillen/followers","following_url":"https://api.github.com/users/lskillen/following{/other_user}","gists_url":"https://api.github.com/users/lskillen/gists{/gist_id}","starred_url":"https://api.github.com/users/lskillen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lskillen/subscriptions","organizations_url":"https://api.github.com/users/lskillen/orgs","repos_url":"https://api.github.com/users/lskillen/repos","events_url":"https://api.github.com/users/lskillen/events{/privacy}","received_events_url":"https://api.github.com/users/lskillen/received_events","type":"User","site_admin":false},"labels":[{"id":50786399,"url":"https://api.github.com/repos/dj-stripe/dj-stripe/labels/bug","name":"bug","color":"e11d21","default":true}],"state":"open","locked":false,"assignee":{"login":"lskillen","id":2248287,"avatar_url":"https://avatars1.githubusercontent.com/u/2248287?v=3","gravatar_id":"","url":"https://api.github.com/users/lskillen","html_url":"https://github.com/lskillen","followers_url":"https://api.github.com/users/lskillen/followers","following_url":"https://api.github.com/users/lskillen/following{/other_user}","gists_url":"https://api.github.com/users/lskillen/gists{/gist_id}","starred_url":"https://api.github.com/users/lskillen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lskillen/subscriptions","organizations_url":"https://api.github.com/users/lskillen/orgs","repos_url":"https://api.github.com/users/lskillen/repos","events_url":"https://api.github.com/users/lskillen/events{/privacy}","received_events_url":"https://api.github.com/users/lskillen/received_events","type":"User","site_admin":false},"assignees":[{"login":"lskillen","id":2248287,"avatar_url":"https://avatars1.githubusercontent.com/u/2248287?v=3","gravatar_id":"","url":"https://api.github.com/users/lskillen","html_url":"https://github.com/lskillen","followers_url":"https://api.github.com/users/lskillen/followers","following_url":"https://api.github.com/users/lskillen/following{/other_user}","gists_url":"https://api.github.com/users/lskillen/gists{/gist_id}","starred_url":"https://api.github.com/users/lskillen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lskillen/subscriptions","organizations_url":"https://api.github.com/users/lskillen/orgs","repos_url":"https://api.github.com/users/lskillen/repos","events_url":"https://api.github.com/users/lskillen/events{/privacy}","received_events_url":"https://api.github.com/users/lskillen/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/dj-stripe/dj-stripe/milestones/3","html_url":"https://github.com/dj-stripe/dj-stripe/milestone/3","labels_url":"https://api.github.com/repos/dj-stripe/dj-stripe/milestones/3/labels","id":1203614,"number":3,"title":"1.0.0","description":"API updates to 2015-07-28","creator":{"login":"kavdev","id":4859329,"avatar_url":"https://avatars1.githubusercontent.com/u/4859329?v=3","gravatar_id":"","url":"https://api.github.com/users/kavdev","html_url":"https://github.com/kavdev","followers_url":"https://api.github.com/users/kavdev/followers","following_url":"https://api.github.com/users/kavdev/following{/other_user}","gists_url":"https://api.github.com/users/kavdev/gists{/gist_id}","starred_url":"https://api.github.com/users/kavdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kavdev/subscriptions","organizations_url":"https://api.github.com/users/kavdev/orgs","repos_url":"https://api.github.com/users/kavdev/repos","events_url":"https://api.github.com/users/kavdev/events{/privacy}","received_events_url":"https://api.github.com/users/kavdev/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":37,"state":"open","created_at":"2015-07-11T23:32:00Z","updated_at":"2017-06-23T09:20:04Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2017-06-23T09:17:30Z","updated_at":"2017-06-29T21:14:22Z","closed_at":null,"body":"At 2:17am this morning we received an 'invoice.upcoming' event via web hooks that ultimately caused our production deployment to skip a beat:\r\n\r\n```\r\nprd  File \"/opt/deploy/prd/.venv/src/dj-stripe/djstripe/event_handlers.py\", line 165, in other_object_webhook_handler\r\nprd    customer=event.customer\r\nprd  File \"/opt/deploy/prd/.venv/src/dj-stripe/djstripe/event_handlers.py\", line 245, in _handle_crud_type_event\r\nprd    stripe_id = stripe_id or event_data[\"object\"][\"id\"]\r\nprd KeyError: 'id'\r\n```\r\n\r\nFor completeness here is an example of the event body:\r\n\r\n```\r\n{\r\n  \"object\":{\r\n    \"application_fee\":null,\r\n    \"livemode\":true,\r\n    \"tax\":0,\r\n    \"attempt_count\":0,\r\n    \"currency\":\"usd\",\r\n    \"total\":0,\r\n    \"statement_descriptor\":null,\r\n    \"next_payment_attempt\":1498785399,\r\n    \"receipt_number\":null,\r\n    \"charge\":null,\r\n    \"closed\":false,\r\n    \"period_end\":1498781799,\r\n    \"forgiven\":false,\r\n    \"metadata\":{},\r\n    \"description\":null,\r\n    \"webhooks_delivered_at\":null,\r\n    \"attempted\":false,\r\n    \"object\":\"invoice\",\r\n    \"paid\":false,\r\n    \"discount\":null,\r\n    \"ending_balance\":null,\r\n    \"date\":1498781799,\r\n    \"period_start\":1496103399,\r\n    \"subtotal\":0,\r\n    \"tax_percent\":0.0,\r\n    \"subscription\":\"sub_foobar\",\r\n    \"customer\":\"cus_foobar\",\r\n    \"lines\":{\r\n      \"has_more\":false,\r\n      \"total_count\":1,\r\n      \"object\":\"list\",\r\n      \"data\":[\r\n        {\r\n          \"discountable\":true,\r\n          \"subscription_item\":\"si_foobar\",\r\n          \"object\":\"line_item\",\r\n          \"description\":null,\r\n          \"proration\":false,\r\n          \"livemode\":true,\r\n          \"period\":{\r\n            \"start\":1498781799,\r\n            \"end\":1501373799\r\n          },\r\n          \"metadata\":{},\r\n          \"currency\":\"usd\",\r\n          \"amount\":0,\r\n          \"plan\":{\r\n            \"object\":\"plan\",\r\n            \"name\":\"FREE\",\r\n            \"created\":1471567097,\r\n            \"interval\":\"month\",\r\n            \"interval_count\":1,\r\n            \"id\":\"product.free-monthly\",\r\n            \"currency\":\"usd\",\r\n            \"amount\":0,\r\n            \"trial_period_days\":null,\r\n            \"livemode\":true,\r\n            \"statement_descriptor\":\"FREE\",\r\n            \"metadata\":{}\r\n          },\r\n          \"quantity\":1,\r\n          \"type\":\"subscription\",\r\n          \"id\":\"sub_foobar\",\r\n          \"subscription\":null\r\n        }\r\n      ],\r\n      \"url\":\"/v1/invoices/in_foobar/lines\"\r\n    },\r\n    \"starting_balance\":0,\r\n    \"amount_due\":0\r\n  }\r\n}\r\n```\r\n\r\nThis isn't an event that is described by the API (that I could see), so my assumption is that this was an error on Stripe's part, and that this is an upcoming (no pun intended) event that hasn't been announced just yet. I've emailed Stripe to ask them about it. Since the `invoice.upcoming` event doesn't refer to objects that exist, we should probably just process the event by ignoring it. Users of the library can still listen for it for informational purposes if they need to."},"comment":{"url":"https://api.github.com/repos/dj-stripe/dj-stripe/issues/comments/312110438","html_url":"https://github.com/dj-stripe/dj-stripe/issues/530#issuecomment-312110438","issue_url":"https://api.github.com/repos/dj-stripe/dj-stripe/issues/530","id":312110438,"user":{"login":"kbrownlees","id":641520,"avatar_url":"https://avatars1.githubusercontent.com/u/641520?v=3","gravatar_id":"","url":"https://api.github.com/users/kbrownlees","html_url":"https://github.com/kbrownlees","followers_url":"https://api.github.com/users/kbrownlees/followers","following_url":"https://api.github.com/users/kbrownlees/following{/other_user}","gists_url":"https://api.github.com/users/kbrownlees/gists{/gist_id}","starred_url":"https://api.github.com/users/kbrownlees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbrownlees/subscriptions","organizations_url":"https://api.github.com/users/kbrownlees/orgs","repos_url":"https://api.github.com/users/kbrownlees/repos","events_url":"https://api.github.com/users/kbrownlees/events{/privacy}","received_events_url":"https://api.github.com/users/kbrownlees/received_events","type":"User","site_admin":false},"created_at":"2017-06-29T21:14:22Z","updated_at":"2017-06-29T21:14:22Z","body":"I just hit this as well, very annoying they don't let you disable it. From the configuration page: \"Event will only be created if billing period is longer than xx days\". I use monthly billing so have set it to 45 days, Hopefully that fixes it for me in the short term.\r\n\r\nIs there a reason _handle_crud_type_event tries to process events that are not CRUD? Or is it actually a more generic handler?"}}
{"actor":{"display_login":"kbrownlees"}}