Skip to content

Disambiguate bulk-license failures and harden Graph batch error parsing for case-colliding keys#29

Closed
Copilot wants to merge 12 commits intodevfrom
copilot/fix-bulk-license-issue
Closed

Disambiguate bulk-license failures and harden Graph batch error parsing for case-colliding keys#29
Copilot wants to merge 12 commits intodevfrom
copilot/fix-bulk-license-issue

Conversation

Copy link

Copilot AI commented Feb 24, 2026

Bulk license failures were surfacing ambiguous error text and, in some cases, a JSON parse exception (keepCopy/KeepCopy) that obscured the actual upstream Graph failure. The issue came from shared Graph batch error normalization and from indistinguishable error-stage messaging in the bulk license flow.

  • Error-source disambiguation in bulk license flow

    • Invoke-ExecBulkLicense now wraps the user lookup batch (New-GraphBulkRequest) in a dedicated try/catch.
    • Lookup failures are rethrown with stage-specific context (before license assignment) so they are not conflated with Set-CIPPUserLicense failures.
  • Case-safe Graph error payload parsing

    • In New-GraphBulkRequest, error JSON parsing now uses ConvertFrom-Json -AsHashtable for ErrorDetails.Message.
    • Message extraction handles both error.message and error.Message to tolerate payloads with inconsistent casing.
  • Scope correction

    • Reverted the earlier entrypoint-level request deserialization change in CippEntrypoints.psm1; fix remains scoped to the actual failing paths.
# Invoke-ExecBulkLicense.ps1
try {
    $UserLookupResults = New-GraphBulkRequest -tenantid $TenantFilter -Requests @($UserLookupRequests)
} catch {
    $LookupError = Get-CippException -Exception $_
    throw "Failed to lookup users before license assignment for tenant $TenantFilter. Error: $($LookupError.NormalizedError)"
}

# New-GraphBulkRequest.ps1
$ErrorJson = $_.ErrorDetails.Message | ConvertFrom-Json -AsHashtable -ErrorAction Stop
$Message = $ErrorJson.error.message ?? $ErrorJson.error.Message
Original prompt

https://raw.githubusercontent.com/Zacgoose/CIPP-API/refs/heads/dev/Modules/CIPPCore/Public/Set-CIPPUserLicense.ps1

Failed to process bulk licence operation: too many child clauses specified in search filter expression containing 'or' operators:71 max allowed is 71


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 3 commits February 24, 2026 22:21
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bulk license operation error for child clauses Chunk bulk license user lookups to stay under Graph OData OR-clause limits Feb 24, 2026
Copilot AI requested a review from Zacgoose February 24, 2026 22:25
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Copilot AI changed the title Chunk bulk license user lookups to stay under Graph OData OR-clause limits Batch bulk user license lookups in groups of 15 to satisfy Graph filter clause limits Feb 24, 2026
@Zacgoose
Copy link
Owner

@copilot can we go even faster by building a bulk request object like what we do for assigning the licence, so it's only 1 api request that we make with multiple 15 long requests

Copilot AI and others added 2 commits February 24, 2026 22:36
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 24, 2026

@copilot can we go even faster by building a bulk request object like what we do for assigning the licence, so it's only 1 api request that we make with multiple 15 long requests

Implemented in 9c837fc: user lookup now builds a single New-GraphBulkRequest payload with 15-user filter chunks, then executes that bulk payload once and aggregates results (with per-chunk failure handling). No UI changes in this update.

Copilot AI changed the title Batch bulk user license lookups in groups of 15 to satisfy Graph filter clause limits Batch bulk user license lookups in groups of 15 via a single Graph bulk request Feb 24, 2026
@Zacgoose Zacgoose marked this pull request as ready for review February 24, 2026 22:43
Copilot AI and others added 2 commits February 25, 2026 14:09
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Copilot AI changed the title Batch bulk user license lookups in groups of 15 via a single Graph bulk request Handle case-colliding request JSON keys in HTTP trigger deserialization Feb 25, 2026
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Copilot AI changed the title Handle case-colliding request JSON keys in HTTP trigger deserialization Fix bulk license error normalization for mixed-case JSON keys in Graph batch failures Feb 25, 2026
Copilot AI changed the title Fix bulk license error normalization for mixed-case JSON keys in Graph batch failures Handle mixed-case JSON keys in Graph bulk error parsing for bulk license failures Feb 25, 2026
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Copilot AI changed the title Handle mixed-case JSON keys in Graph bulk error parsing for bulk license failures Revert incorrect entrypoint fallback and harden Graph bulk error JSON parsing for mixed-case keys Feb 25, 2026
Copilot AI changed the title Revert incorrect entrypoint fallback and harden Graph bulk error JSON parsing for mixed-case keys Fix bulk license failure by hardening Graph batch error JSON parsing for case-colliding keys Feb 25, 2026
Co-authored-by: Zacgoose <107489668+Zacgoose@users.noreply.github.com>
Copilot AI changed the title Fix bulk license failure by hardening Graph batch error JSON parsing for case-colliding keys Disambiguate bulk license failures by separating user-lookup and assign-license error paths Feb 25, 2026
Copilot AI changed the title Disambiguate bulk license failures by separating user-lookup and assign-license error paths Disambiguate bulk-license failures and harden Graph batch error parsing for case-colliding keys Feb 25, 2026
@Zacgoose Zacgoose closed this Feb 28, 2026
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