Skip to content

Introduce Invoke-CIPPRestMethod MVP and route core Graph helpers through it for low-risk REST migration#39

Draft
Copilot wants to merge 8 commits intodevfrom
copilot/create-rest-method-replacement
Draft

Introduce Invoke-CIPPRestMethod MVP and route core Graph helpers through it for low-risk REST migration#39
Copilot wants to merge 8 commits intodevfrom
copilot/create-rest-method-replacement

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 7, 2026

  • Review new PR comment and confirm whether it requires code changes or explanation
  • Check workflow run status on dev and current branch per CI guidance
  • Determine whether the reported variance indicates a regression in the current changes
  • Reply to the PR comment with findings and next-step guidance
  • Make code/test changes only if a concrete regression is identified

Copilot AI and others added 3 commits April 7, 2026 02:04
Copilot AI changed the title [WIP] Investigate replacement for invoke rest method Introduce Invoke-CIPPRestMethod MVP and route core Graph helpers through it for low-risk REST migration Apr 7, 2026
Copilot AI requested a review from Zacgoose April 7, 2026 02:12
@Zacgoose
Copy link
Copy Markdown
Owner

Zacgoose commented Apr 7, 2026

@copilot would be we better off coupling this with a c# or similar compiled method instead of .net methods? No code changes yet just discuss

Copy link
Copy Markdown
Author

Copilot AI commented Apr 7, 2026

@copilot would be we better off coupling this with a c# or similar compiled method instead of .net methods? No code changes yet just discuss

Short answer: not immediately. HttpClient is already compiled .NET, so switching from PowerShell cmdlet calls to C# only helps if we move the hot path (request construction + serialization + response parsing/retry) fully into a compiled cmdlet/library. The current wrapper gives us the right seam to do that later. I’d recommend profiling first, then only adding a C# helper if we see PowerShell overhead dominating after batching/retry/token optimizations. (current tip: b5621bf)

Copilot AI and others added 2 commits April 7, 2026 03:15
Copy link
Copy Markdown
Author

Copilot AI commented Apr 7, 2026

@copilot
Graph Error: Could not get token: Response status code does not indicate success: 400 - Endpoint: users

...

I tracked this to request-body encoding risk in the new HttpClient path and pushed a fix in 05e4891: dictionary/hashtable POST bodies are now sent as application/x-www-form-urlencoded (OAuth/token compatible) instead of JSON/string fallback. I also added coverage in Tests/GraphHelper/Invoke-CIPPRestMethod.Tests.ps1 and re-ran the GraphHelper Pester tests (pass). Please re-test that ListGraphRequest call on this branch.

@Zacgoose
Copy link
Copy Markdown
Owner

Zacgoose commented Apr 7, 2026

@copilot http://localhost:4280/api/ListUserPhoto?UserID=asdhasdasdfsdfdsfds - Exception calling ".ctor" with "3" argument(s): "The format of value 'application/json; charset=utf-8' is invalid."
WARNING: Exception occurred on HTTP trigger (Invoke-ListUserPhoto): Exception calling ".ctor" with "3" argument(s): "The format of value 'application/json; charset=utf-8' is invalid."

Copy link
Copy Markdown
Author

Copilot AI commented Apr 7, 2026

@copilot http://localhost:4280/api/ListUserPhoto?UserID=asdhasdasdfsdfdsfds - Exception calling ".ctor" with "3" argument(s): "The format of value 'application/json; charset=utf-8' is invalid."
WARNI...

Fixed in 487aea5. Invoke-CIPPRestMethod now correctly handles content types like application/json; charset=utf-8 in HttpClient mode by constructing StringContent with the bare media type and then applying the full parsed Content-Type header. Added test coverage in Tests/GraphHelper/Invoke-CIPPRestMethod.Tests.ps1 and re-ran the GraphHelper Pester tests (pass).

@Zacgoose
Copy link
Copy Markdown
Owner

Zacgoose commented Apr 7, 2026

@copilot
it seems the .net method is a bit inconsistent:

cipp .net:
Total time: 238.1s
Requests: 1000 (1000 OK, 0 failed)
Avg duration: 7098ms
Min duration: 2620ms
Max duration: 16704ms
P50: 6240ms
P95: 12197ms
P99: 15365ms
Throughput: 4.2 req/s

Total time: 184.6s
Requests: 500 (500 OK, 0 failed)
Avg duration: 3346ms
Min duration: 2481ms
Max duration: 6143ms
P50: 2989ms
P95: 5094ms
P99: 5694ms
Throughput: 2.7 req/s

rest method:
Total time: 242.6s
Requests: 1000 (1000 OK, 0 failed)
Avg duration: 7192ms
Min duration: 2895ms
Max duration: 15726ms
P50: 6250ms
P95: 11747ms
P99: 12907ms
Throughput: 4.1 req/s

Total time: 189.5s
Requests: 500 (500 OK, 0 failed)
Avg duration: 3395ms
Min duration: 2649ms
Max duration: 7578ms
P50: 3001ms
P95: 4727ms
P99: 7511ms
Throughput: 2.6 req/s

Copy link
Copy Markdown
Author

Copilot AI commented Apr 7, 2026

@copilot
it seems the .net method is a bit inconsistent:

...

These numbers look broadly in-family rather than a clear regression from the REST wrapper—P50/P95 and throughput are very close between both paths, with some run-to-run variance in tail latency. I haven’t made additional code changes from this report alone. If you want, I can add lightweight timing around request build/send/parse in Invoke-CIPPRestMethod behind a debug flag so we can pinpoint where tail jitter is coming from under load.

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