Fix resolution comment length bug when migrating Secret Scanning alerts
Problem
When migrating secret scanning alerts with gh gei migrate-secret-alerts, if the new comment format [@resolverName] originalComment exceeds 270 characters, the GitHub API call fails with an error about comment length limits.
This was introduced in PR #1337 which added the resolver name prefix to resolution comments, but didn't account for the 270 character limit.
Solution
Added length validation before using the prefixed comment format:
- If
[@resolverName] originalCommentis < 270 characters: use the prefixed format (preserves existing behavior) - If
[@resolverName] originalCommentis >= 270 characters: fall back to using only the original comment
This ensures migration completes successfully while preserving the most important content when length limits are exceeded.
Changes
- SecretScanningAlertService.cs: Added comment length check with fallback logic
- SecretScanningAlertServiceTests.cs: Added test cases for both scenarios:
Update_With_Long_Comment_Uses_Original_Comment_Only- verifies fallback behaviorUpdate_With_Short_Comment_Uses_Prefixed_Comment- ensures existing behavior preserved
Example
// Before: Always used prefixed format, could fail on long comments
var targetResolutionComment = $"[@{resolverName}] {originalComment}";
// After: Length-aware with fallback
var prefixedComment = $"[@{resolverName}] {originalComment}";
var targetResolutionComment = prefixedComment.Length < 270
? prefixedComment
: originalComment ?? string.Empty;
All existing tests pass. The fix is minimal and preserves all existing functionality while gracefully handling the edge case.
Fixes #1348.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://www.microsoft.com:80/pkiops/crl/Microsoft%20Identity%20Verification%20Root%20Certificate%20Authority%202020.crl
- Triggering command:
dotnet build src/OctoshiftCLI.sln(http block)http://www.microsoft.com:80/pkiops/crl/Microsoft%20Public%20RSA%20Timestamping%20CA%202020.crl
- Triggering command:
dotnet build src/OctoshiftCLI.sln(http block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
π‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
@dylan-smith I suggest we implement the other option. If new comment = concat original author + original comment has length > 270, trim the new content to the acceptable length (<=270). In practice these migrations are commonly provided as service and executed by a central team therefore preserving the original author (and therefore trail) gives better confidence to customers.
The build gave this error:
/Users/runner/work/gh-gei/gh-gei/src/Octoshift/Services/SecretScanningAlertService.cs(84,66): warning IDE0057: Substring can be simplified
Make sure you run dotnet format src/OctoshiftCLI.sln before every commit.
The build gave this error:
/Users/runner/work/gh-gei/gh-gei/src/Octoshift/Services/SecretScanningAlertService.cs(84,66): warning IDE0057: Substring can be simplified
...
Fixed the IDE0057 warning by running dotnet format which simplified the Substring call to use modern C# range syntax. The build now completes without warnings. Commit: 8f06e3a
Unit Test Results
ββ1 filesββββ1 suitesβββ21s β±οΈ 898 testsβ898 β β0 π€β0 β 899 runsββ899 β β0 π€β0 β
Results for commit 53551377.
:recycle: This comment has been updated with latest results.
Add a bullet point to RELEASENOTES.md describing the change to our users
Add a bullet point to RELEASENOTES.md describing the change to our users
Added a bullet point to RELEASENOTES.md describing the Secret Scanning alert comment length fix for users. Commit: cfea4ab
| Package | Line Rate | Branch Rate | Complexity | Health |
|---|---|---|---|---|
| Octoshift | 87% | 76% | 1439 | β |
| bbs2gh | 82% | 76% | 669 | β |
| gei | 81% | 73% | 596 | β |
| ado2gh | 84% | 78% | 618 | β |
| Summary | 84% (7269 / 8607) | 76% (1708 / 2258) | 3322 | β |