fix checkpoint version parse errors · Entire
fix checkpoint version parse errors
ae9c009·
pfleidi·3w ago·2 files·+11 added/-5 removed
Keep malformed checkpoint_version values as parse errors instead of classifying them as unsupported readable formats.
Unsupported-version detection now only marks known formats this CLI cannot read.
Sessions
f8e660ebe779View transcript
Changes
2
cmd/entire/cli/checkpointpolicy
- Mpolicy.go+1/-5
Mwarning_test.go+10
85 unmodified lines
86
87
88
89
90
91
92
93
89
90
91
92
85 unmodified lines
policy := Normalize(Policy{CheckpointMinVersion: version})
format, err := ParseFormat(policy.CheckpointMinVersion)
if err != nil {
return &unsupportedVersionError{
CheckpointID: checkpointID,
Version: policy.CheckpointMinVersion,
Err: err,
}
return fmt.Errorf("checkpoint %s has invalid checkpoint_version %q: %w", checkpointID, policy.CheckpointMinVersion, err)
}
if !CanRead(format) {
return &unsupportedVersionError{
Mcmd/entire/cli/checkpointpolicy/policy.go+1/-5
26 unmodified lines
27
28
29
30
31
32
33
34
35
36
37
38
39
40
26 unmodified lines
err := checkpointpolicy.EnsureCanReadVersion("abc123", "refs-v1")
require.ErrorContains(t, err, `checkpoint abc123 uses unsupported checkpoint_version \"refs-v1\"`)
require.ErrorContains(t, err, "not read-supported")
require.True(t, checkpointpolicy.IsUnsupportedVersion(err))
}
func TestEnsureCanReadVersionParseErrorIsNotUnsupportedVersion(t *testing.T) {
t.Parallel()
err := checkpointpolicy.EnsureCanReadVersion("abc123", "not-a-format")
require.ErrorContains(t, err, `checkpoint abc123 has invalid checkpoint_version \"not-a-format\"`)
require.False(t, checkpointpolicy.IsUnsupportedVersion(err))
}
Mcmd/entire/cli/checkpointpolicy/warning_test.go+10