You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(repo): stop reporting code scanning languages added by GitHub - #941
Code scanning default setup analyzes the CodeQL languages that GitHub detects in a repository, and GitHub adds the languages it detects later on (see About setup types for code scanning). otterdog compared code_scanning_default_languages exactly with the live settings, so every repository with default setup drifts from its configuration as soon as it contains code:
a new repository can only enable default setup without languages, as validate rejects languages for a repository that does not exist yet or a language that is not detected
once code is pushed, GitHub adds the detected languages, and check-sync reports them on every pull request of the organization until someone adds them to the configuration by hand
For example, check-sync of eclipse-xfsc/.eclipsefdn#50 reports 10 changes, 7 of them only languages added by GitHub, which hide the actual drift (gh_pages_build_type, branch_policies of an environment):
With this PR, the configured languages are the minimum set of languages to analyze:
Empty list: without configured languages, the languages are left to GitHub. They are not compared with the live settings, and an empty list is no longer sent to GitHub, only state and query_suite.
Missing language: a difference is only reported for a configured language that is not analyzed. javascript and typescript count as one, as CodeQL analyzes them together. The change adds the missing language to the analyzed ones instead of replacing them:
Updating the languages: the languages analyzed by the current default setup are read first and kept. This is needed because the apply of a merged pull request compares the configuration with the previous configuration, not with the live settings: without it, adding java-kotlin would remove the python that GitHub added.
The user guide gets a new section "Languages analyzed by GitHub". It now recommends leaving the languages to GitHub and only configuring a language that GitHub does not analyze on its own, e.g. a compiled language.
GitHub API calls only stubbed / mocked in unit tests (no live testing)
Checklist
Documentation updated (docs/, reference docs for new/changed settings, make docs builds)
Default template / examples updated if the config schema changed: not needed, the schema and the default code_scanning_default_languages: [] are unchanged, only their meaning changes
Notes for reviewers
Behavior change: a language that GitHub analyzes can no longer be removed with otterdog, as languages analyzed in addition to the configured ones are kept. This is the intent of the "minimum" semantics, but it changes the previous behavior.
otterdog import: unchanged, it still writes the languages of the live settings. That is harmless now, as they act as a minimum.
Code scanning default setup analyzes the languages that GitHub detects
in a repository, and GitHub adds the languages it detects later on.
As code_scanning_default_languages could neither be configured before
the repository contains code, nor follow what GitHub detects, every
repository with default setup drifted from its configuration: e.g.
check-sync of eclipse-xfsc reported 7 language changes out of 10,
hiding the actual drift.
The configured languages are now the minimum set of languages to
analyze:
- without configured languages (an empty list), the languages are left
to GitHub: they are not compared, and an empty list is no longer sent
to GitHub
- a difference is only reported for a configured language that is not
analyzed, javascript and typescript being analyzed together; the
change adds it to the analyzed languages instead of replacing them
- when updating the languages, the ones analyzed by the current default
setup are kept, as the apply of a merged pull request compares the
configuration to the previous one, not to the live settings
A language that GitHub analyzes can thus no longer be removed by
otterdog.
Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The language-preservation update can remove GitHub-added languages after a failed settings read and reintroduce removed requirements by including previous-configuration values.
Address the review of the pull request:
- When applying a merged pull request, the current repository is the
previous configuration. The change of the languages added the missing
ones to the current languages, so a language removed from the
configuration was applied again, e.g. changing the languages from
python to java-kotlin also sent python. The change now goes from the
configured languages that are already analyzed to the configured
languages: it still only shows the missing ones, and the languages
analyzed on GitHub are only added when the change is applied, from
the live settings.
- The update treated a failed read of the current default setup like a
default setup that is not configured, and could thus remove the
languages analyzed in addition to the configured ones. It now fails
without updating the default setup. The read also keeps the value
javascript-typescript, which is translated anyway, so that the
analysis of JavaScript and TypeScript is kept.
Also align the documentation with the languages being a minimum: a new
repository does not need a second change to configure its languages,
and the troubleshooting guide explains why a language removed from the
configuration is still analyzed.
Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Enabling default setup while shrinking a previously ignored language list can omit the requested language from the PATCH because disabled configurations are incorrectly treated as already analyzing those languages.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Enabling setup can drop newly selected languages
otterdog/models/repository.py:971
When local apply enables default setup while shrinking a previously ignored language list (for example, disabled with ['actions', 'java-kotlin'] → enabled with ['java-kotlin']), this treats the disabled configuration's languages as already analyzed and drops the language change. The resulting PATCH contains only state: configured, so the explicitly requested language is not selected if GitHub's automatic setup does not include it. Treat the previous languages as empty when the previous setup is disabled, and cover this transition in the enabling test.
The reason will be displayed to describe this comment to others. Learn more.
LGTM to apply that logic, I regret supporting that feature due to fact that the live settings are not stable as GitHub adds new languages when it detects them which just is a constant headache.
Also you cant set default languages as long as GitHub has not detected them in the repo, so that also fails often when creating a repo with some default languages from the start. That should probably be disabled alltogether.
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
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.
Description
Code scanning default setup analyzes the CodeQL languages that GitHub detects in a repository, and GitHub adds the languages it detects later on (see About setup types for code scanning). otterdog compared
code_scanning_default_languagesexactly with the live settings, so every repository with default setup drifts from its configuration as soon as it contains code:validaterejects languages for a repository that does not exist yet or a language that is not detectedcheck-syncreports them on every pull request of the organization until someone adds them to the configuration by handFor example,
check-syncof eclipse-xfsc/.eclipsefdn#50 reports 10 changes, 7 of them only languages added by GitHub, which hide the actual drift (gh_pages_build_type,branch_policiesof an environment):With this PR, the configured languages are the minimum set of languages to analyze:
stateandquery_suite.javascriptandtypescriptcount as one, as CodeQL analyzes them together. The change adds the missing language to the analyzed ones instead of replacing them:java-kotlinwould remove thepythonthat GitHub added.The user guide gets a new section "Languages analyzed by GitHub". It now recommends leaving the languages to GitHub and only configuring a language that GitHub does not analyze on its own, e.g. a compiled language.
Related issue
Relates to eclipse-xfsc/.eclipsefdn#50 (comment)
Type of change
Tests
tests/Manual testing
Checklist
docs/, reference docs for new/changed settings,make docsbuilds)code_scanning_default_languages: []are unchanged, only their meaning changesNotes for reviewers
otterdog import: unchanged, it still writes the languages of the live settings. That is harmless now, as they act as a minimum.