❔ Return gets ignored for some godforsaken reason
Despite the
if (cb is null) return NotFound();
the code progresses further, and causes an unhandled exception40 Replies
Use a debugger
I am
The screenshot comes from the debugger, in fact
Well, what happens when you step through the method?
GetClubBar()
? It returns null
Which should trigger the return NotFound()
But... doesn'tI mean, being entirely honest: I don't believe you
If a basic
is null
check was broken, the world would be on fire
Set a breakpoint on that if
check and see what cb
is at that pointYou can see it in the screenshot, the inline value,
cb
is null
Set a breakpoint and see what the value is when the check actually occurs
Given that this is an async method, you're past an await barrier, and
cb
being lifted to a field, it would not surprise me if rider's debugger was lying to you in some fashion where you are right nowUh, huh, it seems if I place the breakpoint there it never gets hit...?
Nor when I place a breakpoint anywhere after
Never hits the return of my
GetClubBar()
method either... so something earlier
What, though...Alright, so probably this screenshot is a broken state of something
Could be
Line 27 bp gets hit, like 49 bp doesn't
So something with the EF query
Wtf does
Nullable object must have a value
mean tho
Isn't the purpose of nullable objects that they can not have a value...?Which of the things that you unconditionally dereference are nullable value types?
Or possibly reference types, not sure how that error gets reported from an EF query
Nothing really jumps out at me
Okay, I'm getting somewhere...
zeroing out everything made it work
Lemme uncomment those one by one
I wonder if
ClubMembers
is null
Mainly because I see it a bunch thereUncommented everything down to
Role
and it works lmao
At least with quick reload
But I also do see the data actually show up
Issue seems to be somewhere her
Since uncommenting it broke the site againWell, return null from the first branch
See if it's the call to
Role
Or could MemberId
be null? You didn't share that model definition
It's a
long
so unlikelyIs
EClubMemberRoles
a reference type?An enum
Hmm
Try casting the first branch of the ternary to a
EClubMemberRoles?
Ignore the warning
And see if that fixes it
No cigar
What about removing the
null
from the other branch
And using default(EClubMemberRoles)
no cigar either
Did you try this?
Yeah, also errors out for some reason
With the same error?
Maybe it's the fault of hot reload, lemme restart the whole thing
doesn't work
I wouldn't use default there
It's not clear what type it binds to
Use
default(TheActualTypeYouWant)
Ah, huh... I brought everything back to this state and it doesn't work
It seems the issue might lie in the
FounderID
...?
When I set the role to null
and founder ID is as it is, it errors
When I hardcode 7
or something to it, it works
Yeah
this worksSo you have a club with no founder?
Might be best to break out a DB explorer and see what data you have
Shit
Seems to be the case, yeah
Club with ID
1
somehow ended up without a founderOops
At least we figured that out
Yeah lol
How did I get to this state, though...
I hate it when projects grow large enough for me to get lost lol
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.