Skip to content

Conversation

@YesuCS
Copy link
Contributor

@YesuCS YesuCS commented Jun 29, 2025

Improve GetSpouse: add null-check

Notice

In case you are submitting a non bug-fix-PR, we highly recommend you to engage in a PR discussion first.

There are many factors we consider before accepting a pull request. This includes:

  1. Whether or not the Rock system you run is a standard, main-line build. If it is not, there is a lower chance we will accept your request since it may impact some other part of the system you don't regularly use.
  2. Features that would be used by less than 80% of Rock organizations, or ones that don't match the goals of Rock.

With the PR discussion we can assess your proposed changes before you start working on it so that we can come up with the best possible approach to it. This may include:

  1. Coming up with an alternate approach that does not involve changes to core.
  2. Advising how your proposed solution be done in a different way that is more efficient and consistent with the rest of the system.
  3. Have one of our core developers make the changes for you. This may be the case if the change involves intricate tasks like an EF migration or something similar.

Proposed Changes

  • Add an early null-check on person.MaritalStatusValue so we return null instead of throwing when it’s missing or not “Married”

  • Preserve the existing LINQ flow for finding the other married adult in the family

Types of changes

What types of changes does your code introduce to Rock?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality, which has been approved by the core team)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • This is a single-commit PR. (If not, please squash your commit and re-submit it.)
  • I verified my PR does not include whitespace/formatting changes -- because if it does it will be closed without merging.
  • I have read the Contributing to Rock doc
  • By contributing code, I agree to license my contribution under the Rock Community License Agreement
  • Unit tests pass locally with my changes
  • I have added any required unit tests or integration tests that prove my fix is effective or that my feature works
  • I have included updated language for the Rock Documentation (if appropriate)

Further comments

This change simply hardens the existing GetSpouse(Person) helper against null data. No behavior changes beyond preventing potential null-reference crashes.

Documentation

No documentation updates needed—this does not affect any public UI or docs.

Migrations

None

Improve GetSpouse: add null-check
@nairdo
Copy link
Member

nairdo commented Jun 30, 2025

@YesuCS Thanks for getting involved like this. Can you share the details on how one can reproduce the issue you're encountering (for this fix)? It didn't quite jump out to me at a quick glance.

@nairdo
Copy link
Member

nairdo commented Jul 9, 2025

@YesuCS Since you might have been out of office last week, I just wanted to check with you again regarding my above question.

@YesuCS
Copy link
Contributor Author

YesuCS commented Jul 9, 2025

Hi Nick! If the first person in the group isn't married, it seemed like we could skip the rest of the loop since a spouse wouldn’t be expected in that case. I added a null check to avoid that, but totally understand if this isn’t a needed change I just started looking for small ways to contribute and open to any feedback.

@nairdo
Copy link
Member

nairdo commented Jul 12, 2025

Ah, I see what you're saying... I guess the other code changes threw me off a bit. If you want to just fix that one comment‡ we'll merge your PR into the develop branch. Thanks in advance!

‡ Somewhere in our Developer Codex we mention writing comments as full sentences (found the link!) but also use only two slashes // for those kinds of comments.

Copy link
Contributor Author

@YesuCS YesuCS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I adjusted the comment to be more clear and formatted correctly.

person.MaritalStatusValue != null &&
person.MaritalStatusValue.Guid.Equals( marriedGuid ) &&
m.GroupRole.Guid.Equals( adultGuid ) )
// Early null check to return null if not married or no spouse found
Copy link
Member

@nairdo nairdo Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YesuCS There's still an indentation issue here (either a tab or spacing problem), but I'm going to merge it and then adjust as needed. Try looking into that for next time.

@nairdo nairdo merged commit 0c43692 into SparkDevNetwork:develop Jul 14, 2025
@nairdo
Copy link
Member

nairdo commented Jul 14, 2025

@YesuCS I forgot to ask... Who are you? We usually know pretty much everyone in the Rock community but I couldn't tell from your GH profile name. Let me know and I'll increment the PR count stat we keep track of for our community members.

@YesuCS
Copy link
Contributor Author

YesuCS commented Jul 15, 2025

my username on rocket chat is yesu.chum! I'm with houstons first baptist church.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants