-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: improve fallback when StringEnum encounters null value #2156
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2156 +/- ##
==========================================
+ Coverage 66.73% 66.77% +0.03%
==========================================
Files 545 545
Lines 14233 14235 +2
==========================================
+ Hits 9498 9505 +7
+ Misses 4735 4730 -5
|
@cliffchapmanrbx @MikhailTymchukDX are either of you able to verify this PR fixes the problem for you? I'd love to be able to confirm this is good before publishing an update to everyone... |
// this should be removed once we can confirm the GitHub API | ||
// is no longer returning a null for the parent Team's | ||
// permission value | ||
return Activator.CreateInstance(type, "null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used null
in my code s well as for the ParameterAttribute for the enum. PermissionLevel
appears to use the word none
as its value though. Do you need to change this to be none
instead of null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer null
here to explicitly indicate no value was found, and I want this to be different to the none
scenario that might be valid here.
In the test itself you'll see that I can't parse out a valid value from this enum.
Assert.Equal("null", result.Parent.Permission.StringValue);
PermissionLevel value;
Assert.False(result.Parent.Permission.TryParse(out value));
This fixes the deserialization issue, and leverages our existing string-like enums to handle unknown values rather than mapping this null
to none
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahha, that makes more sense, thanks!
@shiftkey You'd also need access to our GitHub Enterprise server which might be difficult :) I added a comment about none vs null, I'm a bit slammed with meetings today (under Bay Area shelter in place order) so I'll try and check this as soon as I can. |
@cliffchapmanrbx aha yes, that's also helpful context because you might be working against an older version of the GitHub API depending on your version of GHE |
We keep it up to date specifically to avoid those kinds of problems. Fortunately (?) my next meeting just got cancelled so I've got an hour to play around with this. |
@cliffchapmanrbx do you know which version of GHE you are working against? This will help me to confirm where it was introduced and whether it's been fixed since. |
2.20.2 as of the middle of last week, previously we were on 2.19.5. I don't know if the upgrade caused this issue, or someone shuffling some teams around and suddenly making them nested was what surfaced it. The original bug report is from December. |
I can confirm that we no longer see the error from repos with nested teams. I appreciate the hustle! Do you have an ETA on when this might be available as a new version? I can just re-publish the beta package to our internal feed as a temporary workaround if it's not today or tomorrow. |
Thanks for confirming @cliffchapmanrbx.
Yeah, I suspect that one was also from GitHub Enterprise but I forgot to ask at the time.
Aiming for tonight once I've cleared out some other work. |
release_notes: Fix for deserializing issue when parent team has |
@cliffchapmanrbx the fix has been released https://github.com/octokit/octokit.net/releases/tag/v0.45.0 and is being indexed on NuGet as we speak... |
I just updated my local copy to 0.45.0 and can confirm it is still good. Rolling it out to our internal services now. I really appreciate the quick turnaround on this once we had it isolated 👍 |
@@ -67,7 +67,7 @@ public Team(string url, int id, string nodeId, string slug, string name, string | |||
/// <summary> | |||
/// permission attached to this team | |||
/// </summary> | |||
public StringEnum<Permission> Permission { get; protected set; } | |||
public StringEnum<PermissionLevel> Permission { get; protected set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes Value 'pull' is not a valid 'PermissionLevel' enum value
get thrown when trying to serialize a repo object with codeowners that includes a GH team
Resolves #2052
Testing
To aid with testing this PR, you can add a
NuGet.config
file to the root of your project that adds our beta packages feed:Then, switch your version to the beta release just published, currently
0.45.0-fix-teams-deseri0005
, and try to verify the fix. I'm still working to try and reproduce this on my side, but I have an idea of where it's lurking...