Repository navigation
fix(ci): read complete Swift blobs over 1 MB in the UI approval guard - #24487
Merged
Merged
Conversation
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 4/5
ui-author-approval.cjsrejects valid 10–100 MB Swift blobs without fetching them, even though GitHub supportsgetBlobup to 100 MB. Raise the ceiling to the API limit in both size checks.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/scripts/ui-author-approval.cjs">
<violation number="1" location=".github/scripts/ui-author-approval.cjs:69">
P2: The new 10 MB ceiling leaves valid 10–100 MB Swift blobs unhandled: the guard rejects them without calling `getBlob`, although GitHub supports that endpoint through 100 MB. Use the API's supported bound in both size checks, or explicitly define and justify a 10 MB policy.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| // Contents omits the body above 1 MB (including generated API clients). | ||
| // Read that exact immutable blob instead; generated files still undergo | ||
| // the same UI scan as every other Swift file, on both sides of the diff. | ||
| if (data.encoding === 'none' && data.size > 1000000 && data.size <= 10000000 |
There was a problem hiding this comment.
P2: The new 10 MB ceiling leaves valid 10–100 MB Swift blobs unhandled: the guard rejects them without calling getBlob, although GitHub supports that endpoint through 100 MB. Use the API's supported bound in both size checks, or explicitly define and justify a 10 MB policy.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/ui-author-approval.cjs, line 69:
<comment>The new 10 MB ceiling leaves valid 10–100 MB Swift blobs unhandled: the guard rejects them without calling `getBlob`, although GitHub supports that endpoint through 100 MB. Use the API's supported bound in both size checks, or explicitly define and justify a 10 MB policy.</comment>
<file context>
@@ -62,8 +62,25 @@ async function evidence(github, repo, pr) {
+ // Contents omits the body above 1 MB (including generated API clients).
+ // Read that exact immutable blob instead; generated files still undergo
+ // the same UI scan as every other Swift file, on both sides of the diff.
+ if (data.encoding === 'none' && data.size > 1000000 && data.size <= 10000000
+ && /^[a-f0-9]{40}$/.test(data.sha)) {
+ const metadata = data;
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by David
What changed and why
The UI author approval guard reads changed Swift sources through the GitHub Contents API. For files over 1 MB, such as the generated
desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift, that API returns no body, and the guard fails with "Incomplete Swift source evidence". Any PR that regenerates the OpenAPI types hits this, for example #24477. The guard now fetches the complete blob by its immutable SHA when the Contents API omits the body. Source scanning and fail-closed behavior don't change: if the blob still can't be read, the guard fails as before.The approval workflow runs from trusted main, so this has to land on main before PRs that touch the generated client can pass.
Product invariants affected
None.
How it was verified
.github/scripts/tests/ui-author-approval.test.cjs, with new cases for a Contents response with no body that falls back to the blob, and for a blob fetch failure that still fails closed.Tests
The existing UI approval tests plus the new cases.
Failure class
Failure-Class: none
UI evidence
UI-Evidence: none -- CI guard only
🤖 Generated with Claude Code