subscriptions returned expired subs and not returning active ones
Bug Report
Prerequisites
- [X ] Can you reproduce the problem?
- [X] Are you running the latest version?
- [?] Are you reporting to the correct repository?
- [X] Did you perform a cursory search?
For more information, see the CONTRIBUTING guide.
Description
When my script starts I issue a client.api(`/subscriptions`).get() to find current subs for my app and the expiration. this has been working for about 6 weeks, but today something changed.
logging the result via console.log("all sub", new Date(), res); gets me:
all sub 2022-08-05T18:43:20.891Z {
'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#subscriptions',
'@odata.nextLink': 'https://graph.microsoft.com/v1.0/subscriptions?$skiptoken=<snipped>',
value: [
{
id: <snipped>,
resource: '/teams/getAllMessages?model=B',
applicationId: <snipped>,
changeType: 'created',
clientState: null,
notificationUrl: <snipped>,
notificationQueryOptions: null,
notificationContentType: 'application/json; charset=utf-8',
lifecycleNotificationUrl: <snipped>,
expirationDateTime: '2022-08-05T17:42:12.725Z',
creatorId: <snipped>,
includeResourceData: true,
latestSupportedTlsVersion: 'v1_2',
encryptionCertificate: <snipped>,
encryptionCertificateId: 'SelfSignedCertificate',
notificationUrlAppId: null
}
]
}
If I try to issue a delete for that expired sub, I get a not found error. If I try to subscribe again I get "has reached its limit of '1'" error.
Additionally, my notificationUrl was receiving hits for subscriptions that are not in this list, but as I typed this I've stopped getting any notifications, and subscribing is still saying I'm at my limit.
Usage Information
SDK Version - ["@microsoft/microsoft-graph-client": "^3.0.2" Node Version - [v16.15.0]
I suspect this may be an issue with the Graph servers instead of the SDK. but I am not sure as I've only been using Graph a few weeks.
I added a "get" when I get a notification that wasn't in the original list, it finds it, and in this test case received at 2022-08-05T19:39:24.615Z it has expirationDateTime: '2022-08-05T19:50:27.060Z', which makes sense. why isn't this in the first list?
@wilsonmfg Thank you for reporting the issue! Investigating this :)
just restarted to make sure the issue is persisting, and it's still happening.
@wilsonmfg can you please provide the request ids that you get from Graph response for the get and delete requests?
how do I get the request id? i'm not seeing that in the response or in any samples
Could you try the following suggestion I received from the service team:
The customer should keep following the nextLink to get the entire list of subscriptions, until there is no more nextLink in the response. It is possible and by design that the first call may not return all the data.
'@odata.nextLink': 'https://graph.microsoft.com/v1.0/subscriptions?$skiptoken=
ok, implemented the PageIterator and I get the active ones now, but also a whole lot of expired ones. I wasn't getting expired ones a week ago, and was getting more than one.
Should I be deleting expired ones? seems that's not allowed. this is the result of one:
body: '{"code":"ExtensionError","message":"Operation: Delete; Exception: [Status Code: NotFound; Reason: NotFound]","innerError":{"date":"2022-08-11T13:28:23","request-id":"f8924f00-35e2-4633-8bef-c94ba3dc67b5","client-request-id":"3f4bee52-9b7d-7770-6899-e4415f8f3784"}}'
If I can't delete or renew an expired subscription, why it is it suddenly returning them? it also doesn't allow adding a $filter so I don't have to hit the server a dozen times to get the 2 active ones.
is there a separate place I should open an issue with the service team?
Can you please provide request time + subscription id or subscription id for their original post that is masked?
I don't the exact request time, the response was received 2022-08-05T18:43:20.891Z 4833353e-459f-46a8-823a-7941d14de8fe
What is the subscription id here?
4833353e-459f-46a8-823a-7941d14de8fe ...
Response from service team :
Not yet, we are still looking into the root cause of expired subscriptions in the GET List response. Not related to the issue of expired subscriptions in the results, the customer is sending a Reauth request every five to eight seconds, a practice that is not recommended. Also, they should create a subscription with a longer expiry than half an hour and don't have to patch it every few minutes. We recommend that as a good practice.
I'm only sending a reauth in response to a reauth lifecycle event. I have seen that I get these lifecycle events every few seconds on occasion. I originally had the expiry at 1 hour, but seemed to get reauth events even more then.
the documentation is extremely vague on what causes reauth lifecycle events, but says to respond to them in the way I am doing.
just checked my code, and at some point I switched to doing a renew in response to the lifecycle event which stopped the repeated events where the reauthorize did not. The docs say I can do either.
@nikithauc Thank you for the update!
I am closing this issue since this is solved. I will take it up to the docs to team to indicate the right one.