Skip to content

Commit 5dec658

Browse files
authored
Fix repo-memory validation to skip non-matching files instead of failing (#8286)
1 parent 957f63e commit 5dec658

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

.github/workflows/daily-choice-test.lock.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/setup/js/push_repo_memory.cjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,15 @@ async function main() {
307307
});
308308

309309
if (!matchResults.some(m => m)) {
310-
core.error(`File does not match allowed patterns: ${normalizedRelPath}`);
311-
core.error(`Allowed patterns: ${fileGlobFilter}`);
312-
core.error(`Pattern test results:`);
310+
core.warning(`Skipping file that does not match allowed patterns: ${normalizedRelPath}`);
311+
core.debug(`Allowed patterns: ${fileGlobFilter}`);
312+
core.debug(`Pattern test results:`);
313313
const patternStrs = fileGlobFilter.trim().split(/\s+/).filter(Boolean);
314314
patterns.forEach((pattern, idx) => {
315-
core.error(` ${patternStrs[idx]} -> regex: ${pattern.source} -> ${matchResults[idx] ? "MATCH" : "NO MATCH"}`);
315+
core.debug(` ${patternStrs[idx]} -> regex: ${pattern.source} -> ${matchResults[idx] ? "MATCH" : "NO MATCH"}`);
316316
});
317-
core.setFailed("File pattern validation failed");
318-
throw new Error("File pattern validation failed");
317+
// Skip this file instead of failing - it may be from a previous run with different patterns
318+
return;
319319
}
320320
}
321321

actions/setup/js/push_repo_memory.test.cjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,5 +981,24 @@ describe("push_repo_memory.cjs - glob pattern security tests", () => {
981981
expect(matches).toBe(shouldMatch);
982982
}
983983
});
984+
985+
it("should allow filtering out legacy files from previous runs", () => {
986+
// Real-world scenario: The memory/campaigns branch had old files with incorrect
987+
// nesting (memory/default/...) from before a bug fix. When cloning this branch,
988+
// these old files are present alongside new correctly-structured files.
989+
// The glob filter should match only the new files, allowing old files to be skipped.
990+
const currentPattern = globPatternToRegex("go-file-size-reduction-project64/**");
991+
992+
// New files (should match)
993+
expect(currentPattern.test("go-file-size-reduction-project64/cursor.json")).toBe(true);
994+
expect(currentPattern.test("go-file-size-reduction-project64/metrics/2025-12-31.json")).toBe(true);
995+
996+
// Legacy files with incorrect nesting (should not match)
997+
expect(currentPattern.test("memory/default/go-file-size-reduction-20610415309/metrics/2025-12-31.json")).toBe(false);
998+
expect(currentPattern.test("memory/campaigns/go-file-size-reduction-project64/cursor.json")).toBe(false);
999+
1000+
// This behavior allows push_repo_memory.cjs to skip legacy files instead of failing,
1001+
// enabling gradual migration from old to new structure without manual branch cleanup.
1002+
});
9841003
});
9851004
});

0 commit comments

Comments
 (0)