Repository navigation
docs: correct the branch-protection ruleset so the API accepts it - #1
Merged
Merged
Conversation
The documented command used PUT on the rulesets collection. PUT only
exists on /rulesets/{id} for updating an existing ruleset; creating one
is POST, and PUT on the collection returns a bare 404 Not Found.
Two further shape errors in the JSON, both caught by applying it:
- conditions must be an object, not an array
- "integration_id": null is not an acceptable value; the key must be
omitted entirely so GitHub matches the check by context name
Verified against the live API: all four rules now apply, with
'CI / Build and test' and 'Analyze' required and one code-owner review.
Two defects that made every CodeQL run fail: 1. The Build step ran AFTER the analysis. CodeQL extracts source through the compiler's call graph, so with nothing to process it aborted with 'CodeQL detected code written in Java/Kotlin but could not process any of it'. The steps are now in the order the action actually requires. 2. The workflow lacked security-events: write, so the action could not upload results and logged 'does not have permission to access the CodeQL Action API endpoints'. Verified on the failed run 38122057185.
Previous commit moved Build ahead of Analyze, which fixed the ordering but not the cause: the CodeQL tracer is installed by the init step via LD_PRELOAD, and those variables only reach steps that run after it. The build therefore still ran outside the tracer and analysis found no call graph. Order is now init -> Build -> analyze, which is what the action requires.
The real cause of 'CodeQL could not process any code written in Java/Kotlin' was not the step order. setup-gradle restores the Gradle build cache, so compileDebugKotlin was served FROM-CACHE and never ran: a cached task does not execute, the Kotlin compiler never started, and the tracer captured no call graph. The build still printed BUILD SUCCESSFUL. assembleDebug now runs with --no-build-cache so the compiler genuinely executes under the tracer.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
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.
Fixes the repo's own automation
Three defects that only surfaced once the workflows actually ran. All three are
fixed here.
1. Branch protection could not be applied
The documented command used
PUTon the rulesets collection.PUTonly existson
/rulesets/{id}for updating an existing ruleset; creating one isPOST, andPUTon the collection returns a bare404 Not Found.Two further shape errors in the JSON, caught by applying it for real:
conditionsmust be an object, not an array(
*is not of type 'object'*)"integration_id": nullis not an acceptable value; the key must be omittedentirely so GitHub matches the check by context name
Applied and read back from the live API:
2 and 3. CodeQL failed on every run
Two separate causes, and the first one sent me down the wrong path.
Wrong step order. The workflow ran
analyzebeforeBuild. CodeQL extractssource through the compiler's call graph, so it has to watch a real compile.
The real cause. Fixing the order alone did not help. The actual problem was
that
setup-gradlerestores the Gradle build cache, which servedcompileDebugKotlinasFROM-CACHE. A cached task does not run, so the Kotlincompiler never started and the tracer captured nothing — while the build still
printed
BUILD SUCCESSFUL, which is what makes it so hard to spot:assembleDebugnow runs with--no-build-cachein this job only.Also added the missing
security-events: writepermission, without which theaction cannot upload results and reports failure even when the analysis itself
succeeded.
Verification
CI / Build and test— pass. 334 tests, 26 suites, 0 failures, lint clean,both APKs built.
Analyze (java-kotlin)— pass, 0 code-scanning alerts.Note
This PR is also the ruleset's own first test. The direct
git pushtomaincarrying fix #1 was rejected with
GH013, so the change was routed through apull request like any other.