Skip to content

Commit 0ddfb47

Browse files
authored
Patch experiment with checkpoints not having a name (#2805)
1 parent 84c7d69 commit 0ddfb47

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

extension/src/experiments/model/collect.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,38 @@ describe('collectExperiments', () => {
129129
expect(continuationCheckpoints).toHaveLength(0)
130130
}
131131
})
132+
133+
it('should handle a checkpoint tip not having a name', () => {
134+
const checkpointTipWithoutAName = '3fceabdcef3c7b97c7779f8ae0c69a5542eefaf5'
135+
136+
const repoWithNestedCheckpoints = {
137+
branchA: {
138+
baseline: { data: {} },
139+
[checkpointTipWithoutAName]: {
140+
data: { checkpoint_tip: checkpointTipWithoutAName }
141+
},
142+
tip1cp1: {
143+
data: { checkpoint_tip: checkpointTipWithoutAName }
144+
},
145+
tip1cp2: {
146+
data: { checkpoint_tip: checkpointTipWithoutAName }
147+
},
148+
tip1cp3: {
149+
data: { checkpoint_tip: checkpointTipWithoutAName }
150+
}
151+
},
152+
workspace: { baseline: {} }
153+
}
154+
const acc = collectExperiments(repoWithNestedCheckpoints)
155+
156+
const { experimentsByBranch, checkpointsByTip } = acc
157+
const [experiment] = experimentsByBranch.get('branchA') || []
158+
159+
expect(experiment.id).toStrictEqual(checkpointTipWithoutAName)
160+
expect(
161+
checkpointsByTip.get(checkpointTipWithoutAName)?.length
162+
).toStrictEqual(3)
163+
})
132164
})
133165

134166
describe('collectMutableRevisions', () => {

extension/src/experiments/model/collect.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ const getCheckpointTipId = (
118118
if (!checkpointTip) {
119119
return
120120
}
121-
return experimentsObject[checkpointTip]?.data?.name
121+
122+
const tip = experimentsObject[checkpointTip]?.data
123+
124+
return tip?.name || checkpointTip
122125
}
123126

124127
const transformColumns = (

0 commit comments

Comments
 (0)