From a717db1a90561452d7e70a39717a78814662ab09 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Thu, 12 Mar 2026 11:49:17 +0000 Subject: [PATCH 1/2] Emit warning for unrecognised repo properties with our common prefix --- lib/init-action.js | 5 ++++ src/feature-flags/properties.test.ts | 37 +++++++++++++++++++++++++++- src/feature-flags/properties.ts | 14 +++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/lib/init-action.js b/lib/init-action.js index 9cea791ccd..673e6ad592 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -104401,6 +104401,7 @@ function getUnknownLanguagesError(languages) { } // src/feature-flags/properties.ts +var GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-"; var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; @@ -104445,6 +104446,10 @@ async function loadPropertiesFromApi(logger, repositoryNwo) { } if (isKnownPropertyName(property.property_name)) { setProperty2(properties, property.property_name, property.value, logger); + } else if (property.property_name.startsWith(GITHUB_CODEQL_PROPERTY_PREFIX) && !isDynamicWorkflow()) { + logger.warning( + `Found a repository property named '${property.property_name}', which looks like a CodeQL Action repository property, but which is not understood by this version of the CodeQL Action. Do you need to update to a newer version?` + ); } } if (Object.keys(properties).length === 0) { diff --git a/src/feature-flags/properties.test.ts b/src/feature-flags/properties.test.ts index a468b33493..14d8234806 100644 --- a/src/feature-flags/properties.test.ts +++ b/src/feature-flags/properties.test.ts @@ -4,7 +4,7 @@ import * as sinon from "sinon"; import * as api from "../api-client"; import { getRunnerLogger } from "../logging"; import { parseRepositoryNwo } from "../repository"; -import { setupTests } from "../testing-utils"; +import { RecordingLogger, setupTests } from "../testing-utils"; import * as properties from "./properties"; @@ -197,3 +197,38 @@ test.serial( ); }, ); + +test.serial( + "loadPropertiesFromApi warns if a repository property name starts with the common prefix, but is not recognised by us", + async (t) => { + process.env["GITHUB_EVENT_NAME"] = "push"; + const propertyName: string = `${properties.GITHUB_CODEQL_PROPERTY_PREFIX}unknown`; + sinon.stub(api, "getRepositoryProperties").resolves({ + headers: {}, + status: 200, + url: "", + data: [ + { + property_name: propertyName, + value: "true", + }, + ] satisfies properties.GitHubPropertiesResponse, + }); + const logger = new RecordingLogger(); + const warningSpy = sinon.spy(logger, "warning"); + const mockRepositoryNwo = parseRepositoryNwo("owner/repo"); + const response = await properties.loadPropertiesFromApi( + logger, + mockRepositoryNwo, + ); + t.deepEqual(response, {}); + t.true(warningSpy.calledOnce); + t.assert( + warningSpy.firstCall.args[0] + .toString() + .startsWith( + `Found a repository property named '${propertyName}', which looks like a CodeQL Action repository property`, + ), + ); + }, +); diff --git a/src/feature-flags/properties.ts b/src/feature-flags/properties.ts index 8f52e6d9a6..c9c507f044 100644 --- a/src/feature-flags/properties.ts +++ b/src/feature-flags/properties.ts @@ -1,7 +1,11 @@ +import { isDynamicWorkflow } from "../actions-util"; import { getRepositoryProperties } from "../api-client"; import { Logger } from "../logging"; import { RepositoryNwo } from "../repository"; +/** The common prefix that we expect all of our repository properties to have. */ +export const GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-"; + /** * Enumerates repository property names that have some meaning to us. */ @@ -123,6 +127,16 @@ export async function loadPropertiesFromApi( if (isKnownPropertyName(property.property_name)) { setProperty(properties, property.property_name, property.value, logger); + } else if ( + property.property_name.startsWith(GITHUB_CODEQL_PROPERTY_PREFIX) && + !isDynamicWorkflow() + ) { + logger.warning( + `Found a repository property named '${property.property_name}', ` + + "which looks like a CodeQL Action repository property, " + + "but which is not understood by this version of the CodeQL Action. " + + "Do you need to update to a newer version?", + ); } } From b4937c19e53d395cc647fe16c4e00788a4e7ded3 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 13 Mar 2026 10:56:36 +0000 Subject: [PATCH 2/2] Only emit one message with accumulated property names --- lib/init-action.js | 11 ++++++++--- src/feature-flags/properties.test.ts | 2 +- src/feature-flags/properties.ts | 23 +++++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/init-action.js b/lib/init-action.js index 673e6ad592..a39e890bbd 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -104438,6 +104438,7 @@ async function loadPropertiesFromApi(logger, repositoryNwo) { `Retrieved ${remoteProperties.length} repository properties: ${remoteProperties.map((p) => p.property_name).join(", ")}` ); const properties = {}; + const unrecognisedProperties = []; for (const property of remoteProperties) { if (property.property_name === void 0) { throw new Error( @@ -104447,9 +104448,7 @@ async function loadPropertiesFromApi(logger, repositoryNwo) { if (isKnownPropertyName(property.property_name)) { setProperty2(properties, property.property_name, property.value, logger); } else if (property.property_name.startsWith(GITHUB_CODEQL_PROPERTY_PREFIX) && !isDynamicWorkflow()) { - logger.warning( - `Found a repository property named '${property.property_name}', which looks like a CodeQL Action repository property, but which is not understood by this version of the CodeQL Action. Do you need to update to a newer version?` - ); + unrecognisedProperties.push(property.property_name); } } if (Object.keys(properties).length === 0) { @@ -104464,6 +104463,12 @@ async function loadPropertiesFromApi(logger, repositoryNwo) { logger.debug(` ${property}: ${value}`); } } + if (unrecognisedProperties.length > 0) { + const unrecognisedPropertyList = unrecognisedProperties.map((name) => `'${name}'`).join(", "); + logger.warning( + `Found repository properties (${unrecognisedPropertyList}), which look like CodeQL Action repository properties, but which are not understood by this version of the CodeQL Action. Do you need to update to a newer version?` + ); + } return properties; } catch (e) { throw new Error( diff --git a/src/feature-flags/properties.test.ts b/src/feature-flags/properties.test.ts index 14d8234806..2676c2dcda 100644 --- a/src/feature-flags/properties.test.ts +++ b/src/feature-flags/properties.test.ts @@ -227,7 +227,7 @@ test.serial( warningSpy.firstCall.args[0] .toString() .startsWith( - `Found a repository property named '${propertyName}', which looks like a CodeQL Action repository property`, + `Found repository properties ('${propertyName}'), which look like CodeQL Action repository properties`, ), ); }, diff --git a/src/feature-flags/properties.ts b/src/feature-flags/properties.ts index c9c507f044..12ba280bec 100644 --- a/src/feature-flags/properties.ts +++ b/src/feature-flags/properties.ts @@ -118,6 +118,8 @@ export async function loadPropertiesFromApi( ); const properties: RepositoryProperties = {}; + const unrecognisedProperties: string[] = []; + for (const property of remoteProperties) { if (property.property_name === undefined) { throw new Error( @@ -131,12 +133,7 @@ export async function loadPropertiesFromApi( property.property_name.startsWith(GITHUB_CODEQL_PROPERTY_PREFIX) && !isDynamicWorkflow() ) { - logger.warning( - `Found a repository property named '${property.property_name}', ` + - "which looks like a CodeQL Action repository property, " + - "but which is not understood by this version of the CodeQL Action. " + - "Do you need to update to a newer version?", - ); + unrecognisedProperties.push(property.property_name); } } @@ -153,6 +150,20 @@ export async function loadPropertiesFromApi( } } + // Emit a warning if we encountered unrecognised properties that have our prefix. + if (unrecognisedProperties.length > 0) { + const unrecognisedPropertyList = unrecognisedProperties + .map((name) => `'${name}'`) + .join(", "); + + logger.warning( + `Found repository properties (${unrecognisedPropertyList}), ` + + "which look like CodeQL Action repository properties, " + + "but which are not understood by this version of the CodeQL Action. " + + "Do you need to update to a newer version?", + ); + } + return properties; } catch (e) { throw new Error(