-
Notifications
You must be signed in to change notification settings - Fork 146
Open
Labels
Description
The error occurs in version 9.12+:
This happens when using the webhook API and receiving a POST request from a GitHub webhook.
Cause: type 'String' is not a subtype of type 'Map<String, dynamic>' in type cast
#0 _$RepositoryFromJson (package:github/src/common/model/repos.g.dart:129:48)
#1 new Repository.fromJson (package:github/src/common/model/repos.dart:454:7)
The problematic code is here:
github.dart/lib/src/common/model/repos.g.dart
Lines 127 to 129 in 8169398
organization: json['organization'] == null | |
? null | |
: User.fromJson(json['organization'] as Map<String, dynamic>), |
The data structure looks like this:
{
"repository": {
"id": 677211832,
"node_id": "R_kgDOKF1uuA",
"name": "orgREPO",
"full_name": "whiterOrg/orgREPO",
"private": true,
"owner": {
"name": "whiterOrg",
"email": null
},
...
"html_url": "https://github.com/whiterOrg/orgREPO",
"description": null,
"fork": false,
"master_branch": "main",
"organization": "whiterOrg"
}
}
The issue is that the field organization is a string in this payload, but the code attempts to cast it to a JSON object of type User.