Skip to content
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

feat|fix: adding attribute to skip null properties #329

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ProgrammingByPermutation

Resolves #320


Before the change?

All attributes in the RuleParametersInput were serialized regardless of their null value. This caused the GitHub calls to fail as GitHub incorrectly assumed we were specifying multiple rules at once.

After the change?

Adding the [SerializeIfNotNull] attribute which can be applied to properties serialized by the QuerySerializer to indicate they should never be serialized when null.

As a proof of concept and bug fix, the RuleParameterInput used in the creation of rulesets for the repository was failing due to null properties being serialized into the final output. This code now functions as expected.

I did not make a global change to no longer serialized all null values as I anticipate that there are "side effects" we depend on where there are expected null serializations that will break if such a change is made. This is contrary to the changes proposed in #319 which do not serialize all null properties passed in.

This is an "opt-in" feature that does not disturb the greater ecosystem that may depend on these "side effects". It is also backwards compatible as the rulesets are the only code using this and it was completely failing at the time of creating this PR.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

Adding the [SerializeIfNotNullAttribute] which can be applied to
properties serialized by the QuerySerializer to indicate they should
never be serialized when null.

As a proof of concept, the RuleParameterInput used in the creation of
rulesets for the repository was failing due to null properties being
seralized into the final output. This code now functions as expected.

I did not make a global change to no longer serialized all null values
as I anticipate that there are "side effects" we depend on where there
are expected null serialzations that will break if such a change is
made.

This is an "opt-in" feature that does not disturb the greater echosystem
that may depend on these "side effects".

octokit#320
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 Triage
Development

Successfully merging this pull request may close these issues.

[BUG]: CreateRepositoryRuleset Mutation Failing to Create Rules with Parameters
1 participant