Skip to content

Commit fe337e9

Browse files
fix: a record key that isn't a string matches nothing, falsy or not
`0` and `false` read as an absent key, so such a record could still match this project's block. Check for a nullish key instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LmLXkY5NUqPL7nH2exe9zb
1 parent 8bfd39a commit fe337e9

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎packages/opencode/src/altimate/workspace/memory-sync.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,11 @@ function mirrorIdentityOf(record: CloudMemoryRecord, binding: CachedBinding | nu
429429
if (!blockId || !scope) return undefined
430430
if (scope === "project") {
431431
if (String(m.datamate_id ?? "") !== String(binding?.datamateId ?? "")) return undefined
432-
// The record's key as written. One that isn't a string names no project of
433-
// ours, so it never matches.
432+
// The record's key as written. One that isn't a string, falsy or not, names
433+
// no project of ours, so it never matches.
434434
const recordKey = m.repo_remote ?? m.project_path
435435
if (
436-
recordKey &&
436+
recordKey != null &&
437437
binding &&
438438
!(typeof recordKey === "string" && sameProjectIdentity(recordProjectIdentity(m), projectIdentityFor(binding)))
439439
)

‎packages/opencode/test/altimate/workspace/memory-sync.test.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,13 +2211,16 @@ describe("a repo's URL forms", () => {
22112211
expect(callsTo("/datamates/memory/", "POST").length).toBe(1)
22122212
})
22132213

2214-
test("a record whose remote key isn't a string is not this project's", async () => {
2214+
test("a record whose remote key isn't a string is not this project's, falsy or not", async () => {
22152215
boundTo(HTTPS)
2216-
const record = projectRecord("mem-numeric", "forms-numeric", HTTPS)
2217-
listResponse = [{ ...record, metadata: { ...record.metadata, repo_remote: 42 } }]
2218-
await mirrorBlock(edited("forms-numeric"))
2219-
expect(callsTo("/datamates/memory/mem-numeric", "PATCH").length).toBe(0)
2220-
expect(callsTo("/datamates/memory/", "POST").length).toBe(1)
2216+
for (const [i, key] of [42, 0, false].entries()) {
2217+
captured = []
2218+
const record = projectRecord(`mem-not-string-${i}`, `forms-not-string-${i}`, HTTPS)
2219+
listResponse = [{ ...record, metadata: { ...record.metadata, repo_remote: key } }]
2220+
await mirrorBlock(edited(`forms-not-string-${i}`))
2221+
expect(callsTo(`/datamates/memory/mem-not-string-${i}`, "PATCH").length).toBe(0)
2222+
expect(callsTo("/datamates/memory/", "POST").length).toBe(1)
2223+
}
22212224
})
22222225

22232226
test("a self-hosted record under the binding's own value is updated", async () => {

0 commit comments

Comments
 (0)