Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

PR checks: a read-only token gets a notice from the label job, not a failure (#7850) (#7851)

raykholo4c6382c0a3d8
diff --git a/scripts/pr-checks/pr-checks.js b/scripts/pr-checks/pr-checks.js
index d1ed7aaccd..06ff601131 100644
--- a/scripts/pr-checks/pr-checks.js
+++ b/scripts/pr-checks/pr-checks.js
@@ -132,10 +132,16 @@ async function syncDefaultLabel({ github, context, core }) {
const { status } = parseDefaults(pull.body);
const has = hasLabel(pull, DEFAULT_LABEL);
const args = { ...context.repo, issue_number: pull.number };
- if (status === 'yes' && !has) {
- await github.rest.issues.addLabels({ ...args, labels: [DEFAULT_LABEL] });
- } else if (status !== 'yes' && has) {
- await github.rest.issues.removeLabel({ ...args, name: DEFAULT_LABEL });
+ try {
+ if (status === 'yes' && !has) {
+ await github.rest.issues.addLabels({ ...args, labels: [DEFAULT_LABEL] });
+ } else if (status !== 'yes' && has) {
+ await github.rest.issues.removeLabel({ ...args, name: DEFAULT_LABEL });
+ }
+ } catch (e) {
+ // A fork PR's token is read-only: say so instead of failing the check.
+ if (e.status !== 403) throw e;
+ core.notice(`Could not ${status === 'yes' ? 'add' : 'remove'} the ${DEFAULT_LABEL} label (read-only token); a maintainer sets it.`);
}
core.info(`Defaults line: ${status}`);
}
diff --git a/scripts/pr-checks/pr-checks.test.js b/scripts/pr-checks/pr-checks.test.js
index 7d47392dc7..b64b984f2b 100644
--- a/scripts/pr-checks/pr-checks.test.js
+++ b/scripts/pr-checks/pr-checks.test.js
@@ -136,6 +136,18 @@ test('syncDefaultLabel adds and removes', async () => {
assert.deepEqual(f.calls, [['remove', 'changes-default']]);
});
+test('syncDefaultLabel notes a read-only token instead of failing', async () => {
+ const yes = 'Changes a default: yes — a, old behaviour kept behind preference p';
+ const f = fakes(mk(1, 'a', yes));
+ const notes = [];
+ f.core.notice = (m) => notes.push(m);
+ f.github.rest.issues.addLabels = async () => { throw Object.assign(new Error('Resource not accessible by integration'), { status: 403 }); };
+ await pc.syncDefaultLabel(f);
+ assert.equal(notes.length, 1);
+ f.github.rest.issues.addLabels = async () => { throw Object.assign(new Error('server error'), { status: 500 }); };
+ await assert.rejects(pc.syncDefaultLabel(f));
+});
+
test('checkDefaults only enforces from 2026-10-25', async () => {
const files = [{ filename: 'crates/a.rs' }];
const old = mk(20, 'alice', 'Fixes #5', { created_at: '2026-10-24T23:59:59Z' });