-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Is there an existing issue for this?
- I have searched the existing infra issues
Type of Request
bug
Infrastructure Environment
Cocoon Scheduler in the /api/github/webhook-branch-subscription class.
What is happening?
When the service goes to create a new commit we are getting an error on timestamp which I believe is a result of the timestamp being null. This is an oddity from the github library we are using and from the data returned via the library.
We are calling the following api in the code: /repos/flutter/flutter/commits/6fd42536b7697eb4bd2a698b19308e0aacac70c7 for example.
However that returns the following:
{
"sha": "6fd42536b7697eb4bd2a698b19308e0aacac70c7",
"node_id": "C_kwDOAeUeuNoAKDZmZDQyNTM2Yjc2OTdlYjRiZDJhNjk4YjE5MzA4ZTBhYWNhYzcwYzc",
"commit": {
"author": {
"name": "Xilai Zhang",
"email": "xilaizhang@google.com",
"date": "2023-08-30T02:59:02Z"
},
"committer": {
"name": "GitHub",
"email": "noreply@github.com",
"date": "2023-08-30T02:59:02Z"
},
"message": "[flutter roll] Revert \"Fix `Chip.shape`'s side is not used when provided in Material 3\" (#133615)\n\nReverts flutter/flutter#132941\r\ncontext: b/298110031\r\n\r\nThe rounded rectangle borders don't appear in some of the internal\r\ngolden image tests.",
"tree": {
"sha": "e5efe7f39155d9b8fc40ad0a59c72f6a36f8b66d",
"url": "https://api.github.com/repos/flutter/flutter/git/trees/e5efe7f39155d9b8fc40ad0a59c72f6a36f8b66d"
},
When we get this data back we attempt to create a Commit object from that data which is stored in a RepositoryCommit object. The issue is that we are using commit.author.createdAt. Which is a valid field in the object but not in the data that github is returning.
The createdAt field is also when the user was created. As a temp fix I have just changed this to use the Datetime.now(). I am not sure of the importance of that date.
Steps to reproduce
The cron call to /api/github/webhook-branch-subscription will reproduce the issue with the current code.
Expected results
I expect to see the commit inserted instead of getting this error:
"Failed to process Instance of 'PushMessage'. (500) Invalid argument(s): Error while encoding entity (Bad state: Property validation failed for property timestamp while trying to serialize entity of kind Commit. , #0 _ModelDescription._encodeProperty (package:gcloud/src/db/model_db_impl.dart:449:7)
#1 _ModelDescription.encodeModel.<anonymous closure> (package:gcloud/src/db/model_db_impl.dart:429:7)
#2 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#3 _ModelDescription.encodeModel (package:gcloud/src/db/model_db_impl.dart:428:34)
#4 ModelDBImpl.toDatastoreEntity (package:gcloud/src/db/model_db_impl.dart:121:31)
#5 _commitHelper (package:gcloud/src/db/db.dart:434:38)
#6 Transaction.commit (package:gcloud/src/db/db.dart:118:14)
#7 DatastoreService.insert.<anonymous closure>.<anonymous closure> (package:cocoon_service/src/service/datastore.dart:254:31)
#8 DatastoreDB.withTransaction.<anonymous closure> (package:gcloud/src/db/db.dart:324:32)
#9 _rootRunUnary (dart:async/zone.dart:1407:47)
<asynchronous suspension>
#10 DatastoreService.insert.<anonymous closure> (package:cocoon_service/src/service/datastore.dart:252:11)
<asynchronous suspension>
#11 RetryOptions.retry (package:retry/retry.dart:131:16)
<asynchronous suspension>
#12 DatastoreService.insert (package:cocoon_service/src/service/datastore.dart:250:7)
<asynchronous suspension>
#13 CommitService.handleCreateGithubRequest (package:cocoon_service/src/service/commit_service.dart:42:7)
<asynchronous suspension>
#14 GithubBranchWebhookSubscription.post (package:cocoon_service/src/request_handlers/github/branch_subscription.dart:56:7)
<asynchronous suspension>
#15 RequestHandler.service.<anonymous closure> (package:cocoon_service/src/request_handling/request_handler.dart:53:24)
<asynchronous suspension>
#16 SubscriptionHandler.service (package:cocoon_service/src/request_handling/subscription_handler.dart:138:5)
<asynchronous suspension>
#17 main.<anonymous closure>.<anonymous closure> (file:///app/bin/server.dart:303:11)
<asynchronous suspension>