Skip to content

fix(backend): undefined variables and PS7 ? parsing slips - #914

Merged
KelvinTegelaar merged 1 commit into
CyberDrain:devfrom
kris6673:fix/backend-undefined-vars
Oct 15, 2026
Merged

KelvinTegelaar merged 1 commit into
CyberDrain:devfrom
kris6673:fix/backend-undefined-vars

Conversation

@kris6673

Copy link
Copy Markdown
Contributor

Summary

Variables that are used but never assigned in scope, found with an AST sweep.

Behaviour bugs

  • PS7 null-conditional parsing: in PowerShell 7, ? is a legal variable-name character. So "…/users/$SuspectUser?$select=…"reads$SuspectUser?, which is empty, and $obj?.displayNamereads$obj?`, which is always null.
    • BEC remediate: the username lookup always failed.
    • OneDrive root permissions cache: the owner lookup always failed.
    • Compare-CIPPIntuneObject: labels always fell back to the setting ID.
    • Fixed with $($x)? and ${x}?..
  • Get-CIPPAlertTERRL: called Write-LogMessage -severity, which doesn't exist, so the catch block threw instead of logging.
  • ExecSetMailboxQuota: $quota = New-ExoRequest … overwrote the requested quota. Setting several quota types at once sent the previous EXO result as the next quota.

Log-only fixes
About 15 log calls passed undefined variables, leaving the user, tenant or name empty. Each now uses the variable that is actually in scope.

Testing

  • All 22 files parse cleanly.
  • Verified the PS7 parsing behaviour directly: "$a?" gives an empty string and ${a}?.b returns the value.

- "$Var?" in strings and $Var?.Prop parse as a variable named "Var?" in PS7 (always empty):
  ExecBECRemediate username lookup, OneDrive root permissions owner lookup, Compare-CIPPIntuneObject labels (11 sites)
- Get-CIPPAlertTERRL: -severity is not a Write-LogMessage parameter (-sev)
- Get-CIPPAlertNewMFADevice: ${$IPAddress} -> ${IPAddress}
- ExecSetMailboxQuota: quota was overwritten by the EXO result between branches; message used an undefined $message
- log calls referencing undefined variables ($User, $Tenant, $IntuneBody, $Displayname, $AppDetails, $APIName,
  $ErrorMessage, $GUID, $Request in non-HTTP functions, $name, $tenantfilter, $InstanceId, $Message)
@kris6673
kris6673 marked this pull request as ready for review October 14, 2026 11:05
@KelvinTegelaar
KelvinTegelaar merged commit e29ad37 into CyberDrain:dev Oct 15, 2026
4 of 5 checks passed
@kris6673
kris6673 deleted the fix/backend-undefined-vars branch October 16, 2026 05:53
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