Skip to content

Commit d63d569

Browse files
authored
Merge pull request #50 from processing/uid-typecasting-bug-fix
Fix UID typecasting bug
2 parents 74fad79 + f76089d commit d63d569

22 files changed

Lines changed: 37 additions & 20 deletions

File tree

.github/scripts/assign-event-uids.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ for (const { mpath, meta } of metadatas) {
6161
// Insert uid line after the id line in the frontmatter
6262
const updated_content = content.replace(
6363
/^(---\nid: [^\n]+\n)/m,
64-
`$1uid: ${uid}\n`
64+
`$1uid: "${uid}"\n`
6565
);
6666
await fs.writeFile(contentPath, updated_content);
6767
} catch {

.github/scripts/process-edit-event-issue.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ async function main() {
255255
const markdownLines = [
256256
'---',
257257
`id: ${eventId}`,
258-
...(uid ? [`uid: ${uid}`] : []),
258+
...(uid ? [`uid: "${uid}"`] : []),
259259
'---',
260260
'',
261261
fullDescription,

.github/scripts/process-edit-event-issue.test.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const EXISTING_META = {
4545
intake: { issue_number: 99, submitted_by_github: 'olduser', submitted_date: '2026-01-01', maintainer_notes: '' },
4646
};
4747

48-
const EXISTING_CONTENT = `---\nid: ${TEST_EVENT_ID}\n---\n\nOld content here.\n`;
48+
const EXISTING_CONTENT = `---\nid: ${TEST_EVENT_ID}\nuid: "abc1234"\n---\n\nOld content here.\n`;
4949

5050
function makeEventPayload(body, { number = 10, login = 'edituser' } = {}) {
5151
return JSON.stringify({
@@ -228,6 +228,14 @@ describe('process-edit-event-issue', () => {
228228
assert.equal(content, EXISTING_CONTENT, 'content.md should be unchanged when full_description is blank');
229229
});
230230

231+
test('full_description provided rewrites content.md with quoted uid', async () => {
232+
const { outputs } = await runScript(makeValidEditBody(), { tmpDir, number: 16 });
233+
assert.equal(outputs.valid, 'true');
234+
235+
const content = await fs.readFile(path.join(TEST_EVENT_DIR, 'content.md'), 'utf8');
236+
assert.match(content, /^uid: "[0-9a-f]{7}"$/m, 'content.md uid must be quoted');
237+
});
238+
231239
test('all activities unchecked preserves existing event_activities', async () => {
232240
const body = makeValidEditBody({ activities: '- [ ] Live coding\n- [ ] Exhibition\n' });
233241
const { outputs } = await runScript(body, { tmpDir, number: 12 });

.github/scripts/process-new-event-issue.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ async function main() {
243243
const markdownLines = [
244244
'---',
245245
`id: ${eventId}`,
246-
`uid: ${uid}`,
246+
`uid: "${uid}"`,
247247
'---',
248248
'',
249249
...(fullDescription ? [fullDescription, ''] : []),

.github/scripts/process-new-event-issue.test.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,19 @@ describe('process-new-event-issue', () => {
193193
eventId,
194194
'metadata.json'
195195
);
196+
const contentPath = path.join(
197+
path.resolve(SCRIPTS_DIR, '../..'),
198+
'pcd-website/src/content/events',
199+
eventId,
200+
'content.md'
201+
);
196202
try {
197203
const meta = JSON.parse(await fs.readFile(metaPath, 'utf8'));
198204
assert.equal(meta.id, eventId);
199205
assert.match(meta.uid, /^[0-9a-f]{7}$/);
200206
assert.equal(meta.event_name, 'PCD @ Test City');
207+
const contentMd = await fs.readFile(contentPath, 'utf8');
208+
assert.match(contentMd, /^uid: "[0-9a-f]{7}"$/m);
201209
} finally {
202210
// Clean up the generated event dir
203211
await fs.rm(path.join(

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ No install needed — `open-location-code` is already available at `pcd-website/
6060
Event data lives in `src/content/events/<event-id>/`:
6161
- `metadata.json` — event fields (id, uid, name, location, dates, organizers, etc.)
6262
- `content.md` — markdown body (frontmatter must include `id:` and `uid:`)
63+
- `uid:` values in frontmatter **must always be quoted** (`uid: "abc1234"`) because unquoted hex strings like `1e46977` are parsed as scientific notation by YAML, destroying the value.
6364

6465
`src/lib/nodes.ts` loads all events at Astro build time using `import.meta.glob()` + `getCollection('events')`, validates plus codes with `OpenLocationCode`, decodes lat/lng, and returns a sorted `Node[]` array passed as props to `<MapView>`.
6566

pcd-website/src/content.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const events = defineCollection({
44
type: 'content',
55
schema: z.object({
66
id: z.string(),
7-
uid: z.string(),
7+
uid: z.string().regex(/^[0-9a-f]{7}$/),
88
}).passthrough(),
99
});
1010

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
id: pcd-amsterdam-2026
3-
uid: 847884e
3+
uid: "847884e"
44
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
id: pcd-atlanta-2026
3-
uid: a07b310
3+
uid: "a07b310"
44
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: pcd-bath-2026
3-
uid: bcda01b
3+
uid: "bcda01b"
44
---
55

66
More details coming soon

0 commit comments

Comments
 (0)